Ü
Logical file Versus OPNQRYF
·
The main thing to understand is
that a logical file is a persistent 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.
·
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.
·
Since a LF is a persistent
object it will incur persistent storage needs which will also affect overall
system performance.
·
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. Now if you need a
multiple sort order and random filtering, then maybe you should use OPNQRYF,
but performance will be an issue.
·
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. This of course affects performance, especially with large record
sets that need to be reordered/ recalculated for each update.