You are here: Commands > Index > Indexing versus Sorting

Indexing versus Sorting

The Index command, as an alternative to the Sort command, is usually faster to run and the resulting index file is generally much smaller. However, processing a large indexed file sequentially is significantly slower than processing a large sorted file.

The following table compares the benefits and drawbacks of the Sort and Index commands.

Performance Issue

Sorting

Indexing

Execution speed

Slower

Faster

Resulting file size

Larger

Smaller

Required disk space

More

Less

Subsequent processing of an entire file

Much faster

Much slower

Subsequent processing searching for a few records

Much slower

Much faster

Use the Index command as an alternative to the Sort command only when disk space is very limited or you want to quickly find records with a specific key value.

Note: If you intend to access more than 10 percent of the records in the file, it is better to sort the data in order to optimize subsequent processing speed.

The Index command creates an index file that contains pointers to the records in the open table. These pointers are arranged so that the table can be accessed in a logical order. For example, by turning on the Find Literal option in the Search command, you can locate records with specific key values very quickly, usually in less than one second.