beautypg.com

Compaq COBOL AAQ2G1FTK User Manual

Page 511

background image

Optimizing Your Compaq COBOL Program

15.7 Optimizing File Design (OpenVMS)

For each record moved, a 7-byte pointer to the new record location remains in the
original bucket. Thus, bucket splits can accumulate overhead and possibly reduce
usable space so much that the original bucket can no longer receive records.

Record deletions can also accumulate storage overhead. However, most of the
space is available for reuse.

There are several ways to minimize overhead accumulation. First, determine
or estimate the frequency of certain operations. For example, if you expect to
add or delete 100 records of a 100,000-record file, your database is stable enough
to allow some wasted space for record additions and deletions. However, if you
expect frequent additions and deletions, try to:

Choose a bucket size that allows for overhead accumulation, if possible. Avoid
bucket sizes that are an exact or near multiple of your record size. See the
Bucket Size section below.

Optimize record insertion by using the RMS DEFINE Utility (see the
OpenVMS Record Management Utilities Reference Manual) to define the
file with fill numbers; use the APPLY FILL-SIZE clause when loading the file.

Alternate Keys

Each alternate key requires the creation and maintenance of a separate index
structure. The more keys you define, the longer each WRITE, REWRITE, and
DELETE operation takes. (The throughput of READ operations is not affected by
multiple keys.)

If your application requires alternate keys, you can minimize I/O processing
time if you avoid duplicate alternate keys. Duplicate keys can create long record
pointer arrays, which fill bucket space and increase access time.

Bucket Size

Bucket size selection can influence indexed file performance.

To the system, bucket size is an integral number of physical blocks, each 512
bytes long. Thus, a bucket size of 1 specifies a 512-byte bucket, while a bucket
size of 2 specifies a 1024-byte bucket, and so on.

The Compaq COBOL compiler passes bucket size values to the I/O system based
on what you specify in the BLOCK CONTAINS clause. In this case, you express
bucket size in terms of records or characters.

If you specify block size in records, the bucket can contain more records than you
specify, but never fewer. For example, assume that your file contains fixed-length,
100-byte records, and you want each bucket to contain five records, as follows:

BLOCK CONTAINS 5 RECORDS

This appears to define a bucket as a 512-byte block, containing five records of 100
bytes each. However, the compiler adds I/O system record and bucket overhead to
each bucket, as follows:

Bucket overhead

= 15 bytes per bucket

Record overhead

= 7 bytes per record (fixed-length)

9 bytes per record (variable-length)

Thus, in this example, the bucket size calculation is:

Bucket overhead

= 15 bytes

Optimizing Your Compaq COBOL Program 15–21