RPGPGM.COM - From AS400 to IBM i › Validation: CHAIN versus SETLL
I recently received a message about the post No More Number Indicators. The person asked why I had used a SETLL operation code instead of a CHAIN to check for a record on a file in one of the examples.
I have to credit to my wife for this. Years ago she attended an IBM conference in San Diego, California, and she went to a presentation by John Sears about improving your code's performance. This was one of his suggestions
If you think about what the two operations code do it does make sense.
The CHAIN retrieves a record from the file, and if successful, places the record into the input fields.
The SETLL positions the file pointer at the record it finds with a key that is equal or greater than the key. The %EQUAL built in function, BIF, is "on" when the key searched for is matched to one on the file. The input fields are not loaded.
As the SETLL does not not load the input fields, John Sears explained, it makes it faster and better to use.
The AS400 has become the IBM i, the newer servers and versions of the operating systems mean that programs and database functions run a lot faster. But the logic behind his statement is still valid.
After "digging deep" I did find a reference to this on the IBM website:
SETLL does not cause the system to access a data record. If you are only interested in verifying that a key actually exists, SETLL with an equal indicator (positions 58-59) is a better performing solution than the CHAIN operation in most cases. Under special cases of a multiple format logical file with sparse keys, CHAIN can be a faster solution than SETLL.
You can learn more about this from the IBM website:
This article was written for OS i 7.1, and it should work with earlier releases too.
Sunday September 1: After all the discussion on this subject I decided to go ahead and perform my own test on which is faster, CHAIN or SETLL?
I have created a new post, CHAIN versus SETLL the results, to detail my findings.
Read the original at RPGPGM.COM - From AS400 to IBM i.