× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Richard B Baird wrote:
hey all,

i'm trying to trim a few microseconds per record off of my weekly 2 million
record update.

I've loaded a conversion table into two field array / data structure - the
table is several hundred records.

this is how I coded the array:

D                 DS
D $items                              dim(9999) ascend
D $aItem                              like(AITEM) overlay($items:1) inz(0)
D $pItem                              like(PITEM) overlay($items:*next)
inz(0)

and my lookup looks like this:

C eval $dx = %lookup(CITEMNUM:$aItem:$look1)

C                   if        $dx > 0
C                   eval      CITEMNUM = $pItem($dx)
C                   end

...

here are my questions:

1.  would the lookup be faster if I changed it to a table %tlookup rather
than a paired field array %lookup?

Probably not.



2. does my example above still do a binary search (which i assume is faster) even though the array argument of my lookup bif is only part of the array ds which doesn't have the ascend keyword, while the DIMmed field has the ascend keyword?

The OVERLAY subfields inherit the sequence attribute of the parent. So yes, a %LOOKUP on $AITEM will use a binary search. (Fortunately, $AITEM is at the beginning of the array element. A %LOOKUP on $PITEM would prpbably fail since the elements are probably not in ordered sequence.)


If shaving a few microseconds off your job is important, you could try profiling a search using the C run-time library function "bsearch()". There are three possibilities: It could be faster, it oculd be slower, or perhaps there's no measurable difference. Only your performance testing and analysis can give you a definite answer.

Cheers! Hans



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.