COBOL Manual for TNS/E Programs (H06.08+, J06.03+)

Files With Alternate Keys
You can improve the performance of alternate-key file access by:
Declaring Null Values for Alternate Keys
Making the Main File Entry-Sequenced or Relative
Not Updating the Alternate-Key File Automatically
Declaring Null Values for Alternate Keys
When you create an alternate-key file with FUP CREATE, you can declare a null value for any
alternate key. When you insert a record, if each byte in the alternate-key field contains that null
value, the alternate-key reference is not added to the alternate-key file. This reduces both the size
of the alternate-key file and the access time for the records of a file being accessed according to
that alternate key. It also makes the records that have null values invisible when you read the file
by an alternate key for which a null value has been defined.
If you update a record in the file in such a way that the alternate-key field receives a null value,
the alternate-key reference for that record is deleted from the alternate-key file.
If you read a file according to an alternate key for which a null value has been defined, records
containing the null value of the alternate key are not read.
The most common null values are the ASCII space and the binary zero.
Making the Main File Entry-Sequenced or Relative
If your main file has several keys defined but no one key is used substantially more than any other
keys, consider making that main file a relative or entry-sequenced file rather than a key-sequenced
file.
Every time you read a key-sequenced file by prime key, you cause two possible physical read
operations: one for the key and one for the record. Every time you read a key-sequenced file by
alternate key, you cause four possible physical read operations: one for the alternate key, one for
the alternate-key record, one for the prime key, and one for the record. If the main file has two
keys and the probability of reading the file by any given key is about even, then half the time you
could cause two physical read operations and half the time you could cause four. For each logical
read operation, you average three physical read operations.
If the main file has two keys and the probability of reading the file by any given key is about even,
you also average three physical read operations for each logical read operation if you choose
entry-sequenced or relative organization for the main file; however, if the main file has more than
two keys, the average number of physical read operations per logical read operation improves.
The average number of physical read operations per logical read operation improves even further
when several records in the alternate-key file or main file are in the same physical block and no
physical read is required, such as when you are reading sequentially on an alternate key.
Not Updating the Alternate-Key File Automatically
Another way to improve the performance of alternate-key file access is to specify that the
alternate-key file not be automatically updated by the operating environment when the value of an
alternate-key field changes (use the FUP parameter NOUPDATE). This is appropriate when your
only means of updating the file is a batch update program that runs when no interactive processes
are reading the file; you can run the batch update, then re-create the alternate-key file and reload
it. Do not use the NOUPDATE parameter if the file is updated interactively, because the changed
records do not cause any changes in the alternate-key file until the next batch update.
Partitioned Files
Partitioned files can be accessed faster because separate read heads are used for each partition.
Loss of access to one disk need not mean loss of access to the entire file.
880 Disk Input and Output