User guide

Improving Performance
Using ENFORM Efficiently
058058 Tandem Computers Incorporated 5–9
Removing Alternate Keys. To observe the effect of removing an alternate key that is used
to select a large subset of records, assume that $mkt.sample.employee has an alternate
key field called job, and the alternate key file:
Stores one hundred records (one for each data record).
Has ten data blocks each with ten records.
Has one index block.
Assume also that seventy records in $mkt.sample.employee contain the value
SALESMAN for the job field. When the following query is issued:
OPEN employee;
LIST empnum, empname, job,
WHERE job EQ "SALESMAN";
the query processor must access the alternate key index block, one alternate key data
block, the $mkt.sample.employee index block, and the $mkt.sample.employee data block to
obtain the first record. Assume that both index blocks remain in cache. The query
processor must access approximately 8 of the alternate key data blocks. For each of the
remaining 69 records, it is unlikely that the necessary data file data block is in cache so
the query processor must access the $mkt.sample.employee data blocks 69 different times
to obtain the remaining records. In this case the presence of an alternate key results in
a total of 80 physical file accesses.
If job is removed as an alternate key and the preceding query is issued, the query
processor reads $mkt.sample.employee sequentially, accessing only its index block and
10 data blocks. Removing the alternate key results in a total of 11 physical file
accesses.
The physical file accesses decrease by 88% when the alternate key is removed. The
reduction in physical file accesses will be proportionally similar when a file with a
large number of records is involved.
Avoid Sorting an Already Sorted File
Avoid the processing time ENFORM spends sorting an already sorted file by
including the SEQUENCE IS clause in the dictionary record description. Of course,
the processing time is eliminated only when your query specifies a sorting order that
matches the order specified in the SEQUENCE IS clause. The time eliminated depends
on your query and the size of the file.