The system administrator should monitor the size of FairCom DB data and index files in order to detect unexpected increases in file size. Monitoring file sizes helps avoid running out of disk space or reaching system file size limits and provides useful information in the event of unexpected server performance behavior or resource usage.
Except for files that are created with deleted space reclamation disabled (using the ctADD2END extended create mode), FairCom DB data and index files reuse deleted space. Fixed-length files that reuse deleted space reuse deleted space with complete efficiency and increase in size only after all deleted space has been reused.
Variable-length FairCom DB data files reuse deleted space by indexing deleted space by size and storing new variable-length records in the deleted space that most closely matches the size of the new record. FairCom DB also coalesces adjacent regions of deleted space in variable-length files into a single block of deleted space. Note that a variable-length file may increase in size even if deleted space is available if the available space is not large enough to store a newly-added record. For this reason, depending on the size of variable-length records and the order of insertion and deletion operations on variable-length records, deleted space in variable-length data files can become fragmented over time and the total file size could be larger than might be expected given the total size of active records in the file.
FairCom DB index files reuse space made available in index nodes by deleted key values and reuse nodes that have become empty and are pruned from the tree. A FairCom DB index file grows only when a new node is added and no empty nodes remain that can be reused.
Reducing the size of a FairCom DB data file by removing deleted space from the files can be accomplished by compacting the data file (which also requires rebuilding the associated indexes). The FairCom DB API function CompactIFileXtd() can be used to compact a FairCom DB data file. Note that a file must be opened in exclusive mode in order to compact it.
To reduce the size of a FairCom DB index file by removing deleted nodes, rebuild the index file using the FairCom DB API function RebuildIFileXtd(). Note that this function requires exclusive access to the data file and its associated index files. If index file size is a concern, key compress may help reduce the overall index size by storing key values in compressed format. See the FairCom DB Programmer’s Reference Guide for details on creating an index that contains compressed keys.