01 #low (A15) init full length <H>
01 #high (A15) init full length <H>
I wrote H’00’ and H’FF’ here, but the forum-software seems to cut it out. :?::?:
01 #low (A15) init full length <H>
01 #high (A15) init full length <H>
I wrote H’00’ and H’FF’ here, but the forum-software seems to cut it out. :?::?:
I seem to recall a thread on SAG-L that compared different ways to ascertain if a value exists. Again, just working from memory, I seem to remember that code like:
READ view by desc starting from…
escape bottom immediate
end-read
test *counter from read
was faster than either find number or histogram. will do a search later today or tomorrow.
steve
Sorry; you do not test *counter from the READ, you check the value of the descriptor field. Of course, you should have a small view (preferably just the field in question) to minimize the cost of the READ.
steve
p.s. anyone else having trouble getting replies to post??
From my point of view, Histogram should be faster. Read uses ASSO+DATA. Find number (with range) uses ASSO many times. Histogram (1) with range uses ASSO one time.
I believe your last sentence is incorrect. HISTOGRAM (1) must use the asso as many times as FIND NUMBER. A HISTOGRAM statement always returns *NUMBER to indicate the number of ISN’s for a descriptor value. There is no “count” in Adabas for all the ISNs. Instead, at least as of the last version I looked at, there are “block counts”, which Adabas must add up to produce *NUMBER.
So, if we were only dealing with a small number of ISNs, you are correct. Adabas will get the count from the first block. However, once the number of ISNs starts to span blocks, READ would probably be faster.
As Doug and Ralph both pointed out, any comparison is data dependent.
I, like Doug, tend to use FIND NUMBER to ascertain existence, for all the reasons Doug cited. I also use FIND NUMBER when I need to know “how many”. I use HISTOGRAM when I do not know the values (e.g. How many records have NAMEs that start with “T”. (FIND NUMBER would generate a single ISN list, potentially a lot more expensive than a HISTOGRAM with MULTIFETCH).
Does this approach sometimes cost me a few CPU seconds? Probably. But it also saves hours of my time researching what the data looks like; and time spent by programmers maintaining code to whom FIND NUMBER is self-explanatory, and a READ or HISTOGRAM may be confusing).
steve
I was talking about the following constellation (according to John Smith’s point 6):
*
*
* *NUMBER Descriptor value
* ------- ----------------
* 7 TIM
* 2 TIMOTHY
* 1 TITUS
* 7 TOM
find1.
find number example with surname = 'T' thru 'TZZZZZZZZZZ'
if *NUMBER(find1.) > 0
write "There are surnames beginning with T"
end-if
hist1.
histogram (1) example for surname from 'T' thru 'TZZZZZZZZZZ'
end-histogram
if *COUNT(hist1.) > 0
write "There are surnames beginning with T"
end-if
Which one is faster? Histogram (1) with range or Find number with range? I think it’s Histogram (1).
Does this approach sometimes cost me a few CPU seconds? Probably. But it also saves hours of my time researching what the data looks like; and time spent by programmers maintaining code to whom FIND NUMBER is self-explanatory, and a READ or HISTOGRAM may be confusing).
You’re right, but I used that kind of histogram for consistency check in an Enumerator-Module (where every saved second is very important).