KB#00361-How to calculate the size of an MKEYED file
How to calculate the size of an MKEYED file
Q: What is the calculation to determine how much disk space will be used by a multi-keyed MKEYED file, which has a fixed record size and a fixed number of records? As records are written to the file, the size increases, even though it was created with a fixed number of records (not 0, i.e. dynamic).
A: An MKEYED file with a fixed number of records will still allocate the key area dynamically. This is because it is impossible to predict how much disk space is necessary to accommodate a specific number of keys with any degree of accuracy.
Generally, the data area is approximately NUMBER_OF_RECORDS * RECORD_SIZE bytes. The key area is more complicated. Keys are allocated in 512-byte blocks; with BBx4 using 1024-byte blocks if any key in the file is >64 bytes long. Each key has an 8-byte overhead. A key block has an additional 5-bytes overhead. The largest number of keys that a block will contain must be an even number. At any given point in time, a key block will be from 50% full to 100% full.
With this in mind, you may calculate the number of keys in a key block using the number of bytes per key divided into the block size minus 5 bytes. Taking the integer result, round down to the next smaller even value if odd. This value is the maximum number of keys in each key block in the file.
To determine the minimum number of key blocks necessary to hold N keys you divide the number of records in the file by the maximum number of keys per block, derived above. This will give you the minimum number of blocks necessary to hold N keys. However, since a key block is only guaranteed to be at least 50% full, that could potentially double the number of clocks necessary to hold N keys (in the worst case).
Last Modified: 02/23/2004 Product: PRO/5 Operating System: All platforms
BASIS structures five components of their technology into the BBx Generations.