OPNQRYF vs Logical files

pts.
Tags:
Data analysis
Programming Languages
RPG
What are the advantages and disadvantages of logical files over OPNQRYF command??

Answer Wiki

Thanks. We'll let you know when a new response is added.

Hi

The quick and simple file is that the logical file will already have the index built and therefore has a speed advantage over OPNQRYF which has to build the index before it can be used. The down side to the LF is that it takes up space on the disk.

The primary advantage of the OPNQRYF over logical files is the flexibility of being able to create indexes on the fly as and when needed.

The decision of which to use usually depends on the number of records in the physical and the frequency of use of the index.

Alternatively, embedded SQL is being used more and more for ad-hoc file access.

All the best

Jonathan

==============================================================

The size of a LF is not a downside. The size is negligible. The only downside is that a LF with keys includes an index that usually needs to be updated when records are added to or deleted from the underlying PF. Ongoing index maintenance can become a performance issue when the number of LFs is large and the volume of adds/deletes is also large.

OPNQRYF can replace a LF by having the index built all at once, only when actually requested. If an index is rarely needed, it might be less intrusive over a period of time to build the entire index than to continually be inserting and removing keys from an index.

One distinct advantage of OPNQRYF is that it is the only way to create an index with a key that has subfields from different PFs.

Tom

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following