Sunday, November 22, 2015

Logical File vs OPNQRYF

1. The main difference between Logical file and OPNQRYF is that, Logical file is a permanent object and OPNQRYF is not. Therefore a logical file almost always (depending on your AS400 setup) will have usable access path to sort the records. i.e. access path will be permanent for a logical file.

2. An OPNQRYF will always need to determine what access path to use based on the sort order and filtering set in the command call. If an access plan exists that it can use it will, otherwise it will copy the data and do what is called a table scan to find the records.

3. QRYSLY keyword can be used on OPNQRYF command to setup Record Selection process. Key fields can be mentioned on a File using KEYFLD keyword.

4. Since a LF is a permanent object it will incur permanent storage needs which will also affect overall system performance.

5. If you are always going the same sort order and sequence again and again, then a LF is the best way to go, because it will be almost a readily available access path. It will save the processing time.

6. Now if you need a multiple sort order and random filtering, then maybe you should use OPNQRYF, but performance will be an issue.

7. Another aspect to consider is interactive updating. Persistent Access paths need to frequently update to be useful. Typically the best time for this to happen is when a record gets added or updated.

8. This of course affects performance, especially with large record sets that need to be reordered/ recalculated for each update. Especially when specific logical file doesn’t need to be updated for the process.

9. DYNSLT keyword on Logical File provides an advantage of performing a Selection Criteria during initialization time of program. This method is preferred when there is limited use of specific Logical File.

10. OPNQRYF would be the best option when you have database files with smaller amount of data and you have multiple selection criteria to be applied or criteria can be changed by job.

No comments:

Post a Comment

Different Ways of Sorting Data in a List - Python

Sorting Data in a List List is a collection of data (of different data types), much like an array. Like any data structure or data set, dat...