Sizing Files and Indexes

Files

When you first create a Reality file, you specify a modulo that defines the number of groups (frames) allocated to the file. On a properly sized file, the hashing algorithm used enables in-group items to be accessed in just one disk read.

However, as the file grows, some items will be moved into overflow frames. The more a group overflows, the more disk reads it takes to access items within the group, and the less efficient access becomes. Also, if deleting or updating an item causes a group to shrink, any unused frames outside the primary space are returned to the pool of available space, which can result in inefficient allocation of disk space.

There are two ways of dealing with this:

When deciding which of these methods to use, you should consider the following:

Indexes

The effectiveness of an index depends on selecting the optimum modulo (number of groups). If the modulo is too small, more disk reads will be necessary when using the index, while if it is too large, the index will occupy an excessive amount of disk space.

Because of this, it is recommended that indexes should use automatic file sizing. By default, new indexes (created with CREATE-INDEX) are automatically sized, or you can convert an existing index with the AFS-ENABLE command. When creating a new index, the modulo will be optimised as the index is populated. Note, however, that creating an index will be much quicker if the initial modulo is close to the optimum value - Selecting the Modulo for an Index describes how to calculate the best initial modulo.