Compaq AAQ2G1FTK Marine Radio User Manual


 
Optimizing Your Compaq COBOL Program
15.7 Optimizing File Design (OpenVMS)
To improve I/O access time: ( 1 ) specify a small bucket size, and ( 2 ) use the
BLOCK CONTAINS n RECORDS clause to specify the number of records (cells)
in each bucket. This example creates buckets that contain eight records.
FD A-FILE
RECORD CONTAINS 60 CHARACTERS
BLOCK CONTAINS 8 RECORDS.
.
.
.
In the preceding example, the bucket size is one 512-byte block. Each bucket
contains:
8 records (8 x 60) = 480 bytes
1 overhead byte per record (1 x 8) = 8 bytes
24 bytes of wasted space = 24 bytes
TOTAL = 512 bytes
15.7.2.4 File Size
Calculating a file’s size helps you determine its space requirements. A file’s size
is a function of its bucket size. When you create a relative file, use the following
calculations to determine the number of blocks that you need, rounding up the
result in each case:
Assume that you want to create a relative file able to hold 3,000 records. The
records are 255 bytes long (plus 1 byte per record for overhead), with 4 cells to a
bucket (BLOCK CONTAINS 4 RECORDS). To determine file size:
1. Calculate the number of buckets:
2. Calculate bucket size (see Section 15.7.2.3)
3. Calculate bytes per bucket = (bucket size * number of bytes in a block):
4. Calculate file size:
To allocate the 1500 calculated blocks to populate the entire file, use the APPLY
CONTIGUOUS-BEST-TRY PREALLOCATION clause; otherwise, allocate fewer
blocks.
Before writing a record to a relative file, the I/O system must have formatted
all buckets up to and including the bucket to contain the record. Each time
bucket reformatting occurs, response time suffers. Therefore, writing the highest-
numbered record first forces formatting of the entire file only once. However,
this technique can waste disk space if the file is only partially loaded and not
preallocated.
1518 Optimizing Your Compaq COBOL Program