× 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.



Mike Cunningham wrote:
I need to get data from a file but I know that for every 100 records
I process only 1 will have a record in the file I am going to CHAIN
to. Is it faster to first to a SETLL to see if the key exists and if
it does do a CHAIN or is just doing the CHAIN just as fast? Many
years ago in the S/38 days I know the recommendation was to the SETLL
then the CHAIN.

With RPG/400 (and S/38 RPG III), a CHAIN that doesn't find a record involves an exception. A SETLL that doesn't find an exact record only involves an exception if the search argument is greater than all the records in the file. So with RPG/400, SETLL was indeed better than CHAIN if most of the records were not going to be found.

With ILE RPG, both CHAIN and SETLL use return codes instead of exceptions to communicate "not found"; setting and checking a return code is much much faster than creating and handling an exception. The relative performance of CHAIN and SETLL isn't at all the same as it is for RPG/400.

If the performance difference would really matter, you should do some performance comparisons on your actual file. Set up some hard-coded representative search values, and do your 99% failure + 1% success searches in a loop, CHAIN in one program and SETLL+READ in another. Make the loops run long enough that the entire program takes at least a minute to run, and see if one or the other is noticeably faster. It might be the case that the position of the key within the set of keys makes a difference, so for both the not-found and found cases, you might need to have many different search values to have a representative test.



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.