Compaq COBOL AAQ2G1FTK User Manual

Page 512

Advertising
background image

Optimizing Your Compaq COBOL Program
15.7 Optimizing File Design (OpenVMS)

Total record space is (100 + 7) * 5

= 535 bytes

(Record size is 100 bytes, record
overhead is 7 bytes for each of 5
records)

TOTAL

= 550 bytes

Because blocks are 512 bytes long, and buckets are always an integral number of
blocks, the smallest bucket size possible (the system default) in this case is two
blocks. The system, however, puts in as many records as fit into each bucket.
Thus, the bucket actually contains nine records, not five.

The CHARACTERS option of the BLOCK CONTAINS clause lets you specify
bucket size more directly. For example:

BLOCK CONTAINS 2048 CHARACTERS

This specifies a bucket size of four 512-byte blocks. The number of characters in
a bucket is always a multiple of 512. If not, the I/O system rounds it to the next
higher multiple of 512.

Index Depth

The length of data records, key fields, and buckets in the file determines
the depth of the index. Index depth, in turn, determines the number of disk
accesses needed to retrieve a record. The smaller the index depth, the better the
performance. In general, an index depth of 3 or 4 gives satisfactory performance.
If your calculated index depth is greater than 4, you should consider redesigning
the file.

You can optimize your file’s index depth after you have determined file, record,
and key size. Calculating index depth is an iterative process, with bucket size as
the variable. Keep in mind that the highest level (root level) can contain only one
bucket.

If much data is added over time to an indexed file, you should reorganize the file
periodically to restore its indexes to their optimal levels.

Following is detailed information on calculating file size, and an example of index
depth calculation:

File Size

When you calculate file size:

Every bucket in an indexed file contains 15 bytes of overhead.

Every bucket in an indexed file contains records. Only record type and size
differ.

Data records are only in level 0 buckets of the primary index.

Index records are in level 1 and higher-numbered buckets.

If you use alternate keys, secondary index data records (SIDRs) are only in
level 0 buckets of alternate indexes.

Use these calculations to determine data and index record size:

Data records:

F ixed 0 length record size = actual record size + 7

V ariable 0 length record size = actual record size + 9

15–22 Optimizing Your Compaq COBOL Program

Advertising