Microsoft KB Archive/58018

Method to Estimate Approximate COBOL Index (.IDX) File Size

PSS ID Number: Q58018 Article last modified on 02-07-1990

3.00 3.00a | 3.00 3.00a MS-DOS | OS/2

Summary: The steps below give a rough estimate of the size of a COBOL Version 3.00 or 3.00a index file (which has the filename extension .IDX). The exact size cannot be computed easily, since the COBOL index file uses a tree data structure. Where the nodes split and how full each branch of the tree is depend on how the file was created. This information applies to Microsoft COBOL Versions 3.00 and 3.00a for MS-DOS and MS OS/2.

More Information: The following steps give a rough estimate of how large a COBOL .IDX file will be: 1. Compute the number of bytes for each key. 2. Add 4 bytes to the key length if duplicates are not allowed; otherwise, add 6 bytes to the key length if duplicates are allowed. 3. For each key equal to or less than 120 bytes, one 512-byte block (minimum) is allocated. If the key length is greater than 120 bytes, a 1024 byte block is used. 4. Subtract 4 bytes from the block size (from Step 3 above) for “block overhead.” For example, if the key will use a 512-byte block, the usable block size is 508 bytes. 5. Divide the key size into the usable block size to determine how many keys can fit in a block. 6. Add 2K for header information. This breaks down as follows: Header = 512 bytes Index free space list = 512 bytes Data free space list = 512 bytes (fixed length files only) Key information record = 512 bytes This 2K estimate for the header information is about right, except that the free space lists may not always be present. For instance, they won’t be present when there isn’t any free space in the file. It’s not possible to give an exact formula for the size of this file. Where and when the nodes of the tree structure split and how empty each node is after the split depend entirely on the order in which records are written. If the file is originally built with ACCESS MODE SEQUENTIAL, then the nodes end up more densely packed than for the other ACCESS MODEs.

Example
Consider a record with a prime key PIC X(9) and an alternate key PIC X(15) with 100 records, as follows:

Copyright Microsoft Corporation 1990.