File performance varies considerably from machine to machine and from program to program. This topic discusses general measures that can be taken to improve file handling performance for most situations.
Generally speaking, sequential files are fastest and indexed files are slowest. Relative files are usually in between in performance, but are generally close to sequential files in speed.
When designing indexed files, you should try to keep the size and number of keys to a minimum. Each key added to a file significantly increases the processing time required. The key size is important because it affects how many keys can be stored in one disk block. If you are faced with a decision that trades off making a new key or making an old key larger, it usually is better to make the old key larger.
One important and often overlooked aspect of file performance is file locking. Generally speaking, the more restrictive the access to a file, the more efficiently that file can be processed. On some machines, the difference can be quite dramatic. For example, under RMS, writes to a sequential file are usually at least five times faster if that file is locked for exclusive use. If this is a report file, there is no reason not to lock the file, and the report program will run much faster if you do so.
As a general rule of thumb, you should lock files as restrictively as you can, given the needs of your application. Note that if you have a file that is read by many programs, but rarely or never written to, you can open the file for INPUT ALLOWING READERS. This allows many users to access the file, but also tells the runtime system that it is not being updated by anyone. The runtime system can use this knowledge to buffer the file more effectively. One common form of file where this technique can be used is a file that contains menu options or screen layouts.
On the other hand, you should lock records only when you need to. While locking a record is generally fairly fast, the time to do so increases proportionally to the number of locks you are holding. Also, on networked file systems, locking records can be fairly slow because the networked machines must all be informed of the lock. Note that this is another reason to lock files when possible: when the file is locked, the runtime does not need to establish locks on individual records.
If you have enough memory, you can also increase your indexed file performance by increasing the V-BUFFERS configuration option described in Appendix H. This will increase the number of disk buffers used by the runtime system to hold key information.
Finally, you should read the information on the MASS-UPDATE option described in Mass Update, as well as the Bulk Addition option described in Bulk Addition Mode for Vision. Using these options can significantly improve performance on some machines.