Find Number vs Histogram

I relatively new to Natural and Adabas and have read what seems confusing information about when to use a FIND NUMBER and when it’s best to use a HISTOGRAM. I’ve searched this site and have not found any information on this. From what I understand the main differences between these statements are:
FIND NUMBER:

  • just accesses the Associator’s Inverted List (Normal Index)
  • does not start a processing loop. So no Adabas ‘RC’ command.
  • does not have access to any key (Descriptor/Super Descriptor) data - meaning it will not be available in the FIND NUMBER to Display, etc.

HISTOGRAM:

  • also, just accesses the Inverted List
  • does start a processing loop, so does generate an additional ‘RC’ command
  • does have access to key fields (DESC, SD) to be displayed etc. in the Histogram loop.

I read somewhere that if the view used for the Histogram is defined in an external LDA, that, that was the only thing that could be included in the LDA. But I don’t think this is correct. I do know that the only thing that can be included in the Histogram view is the Descriptor/SuperDesc being used in the Histogram statement.

If any of the above is incorrect, please correct.

Having said all this, I still do not know if one is more efficient than the other and under what conditions?

You are correct in your “compare and contrast” of HISTOGRAM and FIND.

You also are correct in your understanding of what can go into an external LDA. The HISTOGRAM view is restricted to a single DE, but the LDA is not restricted.

As to where to use one or the other …

FIND creates an ISN list and then counts them whereas HISTOGRAM summarizes a count field (count of ISNs per Associator block), so, in general, HISTOGRAM is faster, despite the RC.

One thing to remember is always to use the TO clause in the HISTOGRAM, to avoid processing additional Associator blocks.

I use FIND NUMBER to test whether a unique key value exists. For example, SSN is unique on a master file. But for an account number on a transaction file, I would use HISTOGRAM rather than have FIND count hundreds or thousands of ISNs for the associated transactions.