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:
file size (in blocks) =
511 + (number of buckets 3 bytes per bucket)
512
number of buckets =
number of records in the file
number of cells per bucket
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:
750 =
3000
4
2.
Calculate bucket size (see Section 15.7.2.3)
2 =
4 3 (1 + 255)
512
3.
Calculate bytes per bucket = (bucket size * number of bytes in a block):
1024 = 2 3 512
4.
Calculate file size:
1500 =
511 + (750 3 1024)
512
file size = 1500 physical blocks
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.
15–18 Optimizing Your Compaq COBOL Program
Содержание COBOL AAQ2G1FTK
Страница 22: ......
Страница 30: ......
Страница 94: ......
Страница 110: ......
Страница 146: ......
Страница 180: ......
Страница 194: ...Processing Files and Records 6 1 Defi...
Страница 300: ......
Страница 490: ......
Страница 516: ......
Страница 517: ......
Страница 530: ......
Страница 534: ......
Страница 590: ......
Страница 620: ......