Optimizing Your Compaq COBOL Program
15.7 Optimizing File Design (OpenVMS)
15.7.2.3 Bucket Size
A bucket’s size is from 1 to 63 blocks. A large bucket improves sequential access
to a relative file. You can prevent wasted space between the last cell and the end
of a bucket by specifying a bucket size that is a multiple of cell size.
If you omit the BLOCK CONTAINS clause, the system calculates a bucket size
large enough to hold at least one cell or 512 bytes, whichever is larger (that
is, large enough to hold a record and its overhead bytes). Records cannot cross
bucket boundaries, although they can cross block boundaries.
Use the BLOCK CONTAINS n CHARACTERS clause of the file description to set
your own bucket size (in bytes per bucket). Consider the following example:
FILE-CONTROL.
SELECT A-FILE
ORGANIZATION IS RELATIVE.
.
.
.
DATA DIVISION.
FILE SECTION.
FD A-FILE
RECORD CONTAINS 60 CHARACTERS
BLOCK CONTAINS 1536 CHARACTERS
.
.
.
In the preceding example, the bucket size is 3 blocks. Each bucket contains:
25 records (25 x 60) = 1500 bytes
1 overhead byte per record (1 x 25) = 25 bytes
11 bytes of wasted space = 11 bytes
TOTAL = 1536 bytes
If you use the BLOCK CONTAINS CHARACTERS clause and specify a value
that is not a multiple of 512, the I/O system rounds the value to the next higher
multiple of 512.
In the following example, the BLOCK CONTAINS clause specifies one record per
bucket. Because the cell needs only 61 bytes, there are 451 wasted bytes in each
bucket.
FILE-CONTROL.
SELECT B-FILE
ORGANIZATION IS RELATIVE.
.
.
.
DATA DIVISION.
FILE SECTION.
FD A-FILE
RECORD CONTAINS 60 CHARACTERS
BLOCK CONTAINS 1 RECORD.
.
.
.
Optimizing Your Compaq COBOL Program 15–17