Compaq COBOL AAQ2G1FTK User Manual

Page 510

Advertising
background image

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

A data level bucket may not be large enough to contain a new record. In this
case, the I/O system inserts a new bucket in the chain, moving enough records
from the old bucket to preserve the key value sequence. This is known as a
bucket split.

Data bucket splits can cause index bucket splits.

15.7.3.1 Optimizing Indexed File I/O

I/O optimization of an indexed file depends on five concepts:

Records—The size and format of the data records can affect the disk space
used by the file.

Keys—The number of keys and existence of duplicate key values can affect
disk space and processing time.

Buckets—Bucket size can affect disk space and processing time. Index depth
and file activity can affect bucket size.

Index depth—The depth of the index can affect bucket size and processing
time.

File size—The length of files affects space and access time.

Records

Variable-length records can save file space: you need write only the primary
record key data item (plus alternate keys, if any) for each record. In contrast,
fixed-length records require that all records be equal in length.

For example, assume that you are designing an employee master file. A variable-
length record file lets you write a long record for a senior employee with a large
amount of historical data, and a short record for a new employee with less
historical data.

In the following example of a variable-length record description, integer 10 of the
RECORD VARYING clause represents the length of the primary record key, while
integer 80 describes the length of the longest record in A-FILE:

FILE-CONTROL.

SELECT A-FILE ASSIGN TO "AMAST"

ORGANIZATION IS INDEXED.

DATA DIVISION.
FILE SECTION.
FD

A-FILE
ACCESS MODE IS DYNAMIC
RECORD KEY IS A-KEY
RECORD VARYING FROM 10 TO 80 CHARACTERS.

01

A-REC.
03

A-KEY

PIC X(10).

03

A-REST-OF-REC

PIC X(70).

.
.
.

Buckets must contain enough room for record insertion, or bucket splitting
occurs. The I/O system handles it by creating a new data bucket for the split,
moving some records from the original to the new bucket, and putting the pointer
to the new bucket into the lowest-level index bucket. If the lowest-level index
bucket overflows, the I/O system splits it in similar fashion, on up to the top level
(root level).

In an indexed file, the I/O system also maintains chains of forward pointers
through the buckets.

15–20 Optimizing Your Compaq COBOL Program

Advertising