An index is used to read records in sorted order and to improve performance when selecting records and joining database files. Paradox indexes are stored in separate files and are either
primary or
non-primary.
A primary index is made up of one or more fields from the Paradox database file. The primary key fields of a primary index consist of one or more consecutive fields in the database file, beginning with the first field in the database file. A database file can have only one primary index.
Collectively, the primary key fields uniquely identify each record in the Paradox database file. Thus, no two records in a Paradox database file can share the same values in their primary key fields. Once a primary index is created for a Paradox database file, the database file’s records are re-ordered based on the primary key fields. At the time a primary index is created, if any records have matching primary key field values, Paradox deletes all but the first record. Paradox creates this index as maintained; that is, if you modify, add, or delete records in the database file, the primary index is updated automatically to reflect these changes.
A primary index is a single file with the same name as the database file on which it is based but with a .PX extension.
A non-primary index is defined by specifying one or more fields in the Paradox database file that constitute the non-primary key field. It allows Paradox to sort each record in the database file according to the values of the non-primary key fields.
There are two kinds of non-primary indexes: maintained and non-maintained. A maintained index is automatically updated when the database file is changed, whereas a non-maintained index is not. Instead, a non-maintained index is tagged out-of-date and is updated when the index is used again.
The Paradox driver uses non-maintained indexes only for read-only queries on locked database files. A primary index is not required for the non-maintained index to be used.
For Paradox 3.x, a single non-primary index consists of a pair of files with the same name as the database file on which the non-primary index is based; one of these files has an .X
nn extension while the other has a .Y
nn extension (where the hexadecimal number
nn corresponds to the field number of the non-primary key field for the non-primary index).
For Paradox 4.x, 5, 7, 8, 9, and 10 single-field, non-primary indexes that are case-sensitive have the same name as their associated database file and are assigned file extensions .X01 through .XFF, depending on the number of the field on which the index is based. Single-field, non-primary indexes that are case insensitive and composite indexes have the same name as the database file on which they are based. They are assigned file extensions sequentially starting with .XG0 (with hexadecimal increments).