Automatic File Sizing

Automatic file sizing allows files to expand by increasing the number of allocated groups beyond that defined by the modulo. The file grows one group at a time by splitting the items in a single group between their current group and a new group appended to the file. On the next expansion, the next group is split. This continues until all the original groups have been split and the number of groups is twice the modulo; at this point, the modulo is doubled and the process starts again.

Contraction is the exact opposite. Each appended group is combined with the corresponding group in the main part of the file. When no appended groups remain, the modulo is halved, again splitting the file into main and appended sections, and the process starts again. Note, however, that if the current modulo is an odd number, once any appended groups have been removed the file cannot be contracted any further.

Files expand automatically as they are updated and can also be forced to expand if required. You have to force a file to contract (see Expanding and Contracting Manually).

When deciding whether to use automatic file sizing, you should consider the following:

Notes:

  • File and master dictionaries cannot be configured for automatic file sizing; they always use standard hashing.
  • Indexes can also be configured to be resized automatically. New indexes created with CREATE-INDEX will be automatically sized unless you specify otherwise. A file and its indexes can be independently configured for automatic file sizing.
  • Most of the AFS commands can only be run by the database owner. Refer to command descriptions for details.
  • You can use the LISTFILES command to find out whether a file is automatically sized.

Creating an Automatically Sized File

The AutoFileSize database configuration parameter allows you to specify automatic file sizing as the default for your database - all new files will be automatically configured for automatic resizing.

If AutoFileSize is not set, you can create an automatically sized data section by using the A option with the CREATE-FILE command, or by selecting autosize mode with the AFS-SET command before running CREATE-FILE. For example:

CREATE-FILE ADDRESSES 7 13 (A

or

AFS-SET
CREATE-FILE ADDRESSES 7 13

Notes:

  • The AFS-CLEAR command cancels the effect of AutoFileSize and AFS-SET.
  • If you specify a modulo when creating an automatically sized data section, this will set the initial modulo. If this is close to the data section's optimum size, it will result in faster file population. Also, for files that are expected to grow only slowly, if at all, setting the best modulo from the outset will reduce disk fragmentation.
  • Because of interaction with other parts of the Reality system, modulos that are multiples of 11 are not recommended.

Converting an Existing File to use Automatic File Sizing

Existing data sections can be converted to use automatic file sizing by using the AFS-ENABLE command. For example, to convert the default data section of the file ACCOUNTS, use:

AFS-ENABLE ACCOUNTS

Note

AFS-ENABLE can also be used to convert indexes to be resized automatically. A file and its indexes can be independently configured for automatic file sizing.

You can use the AFS-SELECT command to scan the files in your database to determine which would benefit from using automatic file sizing. The select list produced can then be used as input to AFS-ENABLE.

Expanding and Contracting Manually

You can force an AFS file to expand with the AFS-EXPAND command. By default, the expansion stops when the modulo doubles. You can specify a different expansion factor if you wish.

It can take a long time to fully expand a large file. Because of this, AFS-EXPAND can be interrupted and resumed later. It can also be run in the background - the expansion will continue after the user has logged off.

The following example runs AFS-EXPAND in the background to expand the ACCOUNTS file's default data section by 50%:

AFS-EXPAND ACCOUNTS (B50

If you need to contract an AFS file, use the AFS-CONTRACT command. By default, the file is contracted until there are no appended groups; if there are no appended groups, the modulo is halved. You can also specify the percentage by which to contract.

Caution

Contracting a file should only be performed when a file is not being accessed by other processes. A process performing sequential access to a file while it is being contracted may get incorrect results.

The following example runs AFS-CONTRACT in the background to contract the ADDRESSES file's LOCAL data section to the current modulo:

AFS-CONTRACT ADDRESSES,LOCAL (B

Note

When a file that is configured for automatic file sizing is cleared with the CLEAR-FILE command, the file is contracted to its original modulo.

You can use your file save statistics to decide how much you need to expand or contract an AFS file. List the appropriate data section in STAT-FILE, using the W.UNDERSIZED.FILES or W.OVERSIZED.FILES macro.

Other Automatic File Sizing Tasks