The key file structure allows individual keys to be optimized for maximum access and update speed. This optimization involves setting the mean size of a node in the key structure. The optimizing parameter is computed by the DEFINE-KEYS program based upon the average key size that you entered when you created the key. Consider an example where the CUSTOMERS file key number 1 consists of:
Customer name |
Average 20 characters |
Separator character |
1 character |
item-ID |
Average 6 characters |
This makes the average key length 27 characters. The actual key structure adds 1 additional character as a separator which brings this value to 28 characters. The size of a node should be slightly less than one frame for best performance.
If the DEFINE-KEYS program computes the optimizing parameter as 28, then for this example the node size is 64*28 = 1792, which is very close to optimum. If the key is larger or smaller, the number of elements in a node should be adjusted accordingly. The DEFINE-KEYS command lets you tell the system the average size of the key (including the size of the item-ID). It then uses this information to compute the best optimizing parameter.
One slightly unusual side-effect occurs because of the unlimited item-size capability of the host. Whenever an item grows larger than some pre-defined percentage of a frame, the item is stored as an indirect item. This is not a desirable situation for a key file.
Therefore, the key file item size should be kept below this threshold, if possible. The DEFINE-KEYS computation of the optimizing parameter takes this into account for systems with unlimited item-size file structures.
The key files are designed so they cannot overflow regardless of how large files are or how many keys are stored. The host is not capable of addressing enough disk drive space to store a file big enough to overflow the key structure.
See Also
Using the BTREE File Structure System
Using Lookup and Browse Routines
Source Code to Lookup Routines
Maintaining Key File Performance
Stack Code Calculator Function