ISAM index density
Three forms of index density occur during file updates:
- Natural fill or default density during insertions. Index blocks are always filled to maximum capacity and then split in half (50/50). Occurs when neither key or file density is specified.
- Balanced fill during random insertions. Index blocks are filled to maximum capacity, balanced by rotating key entries between adjacent blocks to avoid splitting, and then split in half (50/50). Key rotation fills adjacent blocks to the specified density first and then fills the current block to maximum capacity before splitting. Occurs when key or file density is specified.
- Context fill during sequential insertions. Index blocks are filled to maximum capacity, and sequential keys generate a split at the specified density.
Occurs when key or file density is specified.
A split generates between 3 and (2 * index depth) + 1 file writes with almost certain file extension. A rotation generates no more than 3 writes and no file size extension.
Natural fill is enabled by default (in other words, if you don’t specify the file or key density options). Balanced and context fill are enabled for all keys when the file density option is specified, or for the specified keys when the key density option is specified. Routine file updates (STORE, WRITE, and DELETE) use the defined density form and pack indexes accordingly. In addition, the isutl utility (-rp option) can be used to pack indexes to a desired density without changing the defined density option.
Keys stored randomly using natural fill will typically fill to about 68 percent, while keys stored sequentially will fill to 50 percent. Keys stored randomly using balanced fill will typically fill to about 73 percent (when defined density is 80 or higher), while keys stored sequentially will fill to the defined density.
We believe natural fill is best for files that regularly have large volumes of file updates, and it should be followed up by running isutl at regular intervals to optimize the indexes. For files that normally have few updates, like window libraries, archives, and other read-only files, use the natural fill and then use the isutl -rp option to pack the indices to 100 percent. This will reduce the size of the file by compacting the indexes and improving read performance.
Keys that represent a sequence number or any continually increasing value that grows sequentially (such as a key based on time) where insertions to the middle of the sequence are rare may be candidates for context fill at 100 percent density. If these keys allow duplicates, make sure the duplicates are inserted at the end. The STORE operations will maintain the index density at 100 percent. Keys of this nature take up half the space normally taken by keys with no specified density.
File creation density options
- File density. The file density designates the key density for each index when the file is created. If specified, each index is populated with a matching key density, and then the file density is discarded from the file options. The isutl utility (with the -qfile=density option) can be used to add or change the file density option, which in turn adds or changes the key density option for each index.
- Key density. The key density designates how a specific index will be packed during update operations.