Firebird Maestro online Help
Prev | Return to chapter overview | Next |
Indexes
Indexes are primarily used to enhance database performance (though inappropriate use may result in slower performance). The key field(s) for the index are specified as column names, or alternatively as expressions written in parentheses in Firebird server version 2.0 and higher. Multiple fields can be specified if the index method supports multicolumn indexes.
Table indexes are created within the Index Properties dialog window. In order to open the dialog you should either
or
or
|
Table indexes are edited within the Index Properties dialog window. In order to open the dialog you should either
or
You can change the name of the index using the Rename Index dialog. To open the dialog you should either
or
|
To drop the table index:
or
and confirm dropping in the dialog window.
|
Use the Columns drop-down list to select a key field(s) for the index.
Expression
This field is available since Firebird 2.0. An index field can be an expression computed from the values of one or more columns of the table row. This feature can be used to obtain fast access to data based on some transformation of the basic data. For example, an index computed on upper(col) would allow the clause WHERE upper(col) = 'JIM' to use an index. To set the index expression, use the Add expression button and enter the expression in the corresponding window.
Example
Suppose, there is a table Employee with the salary and premium fields and queries as follows are executed very often.
SELECT *
FROM "Employee"
WHERE "salary"+"premium">5000;
To create an index making such queries faster, set salary+premium as the index expression.
Primary key constraint
With this option checked this field becomes a compound primary key. It is useful in case the table has more than one primary key.If checked, creates a primary key constraint. Defines primary key constraint of table. A primary key is one or more columns, and their collective contents are guaranteed to be unique. A primary key column must also define the NOT NULL attribute. A table can have only one primary key.
Unique constraint
Check the option to permit no duplicate values. A unique column must also define the NOT NULL attribute. A table can have one or more unique keys.
Unique Index
If checked, creates a unique index for the table, i.e. the database system ensures that no two rows of the specified table have the same values in the indexed columns. In this way, if two rows both contain the NULL value for all columns of an index, the two index values are not considered to be identical. If at least one column does not contain the NULL value, two rows that have the same value in all non-NULL columns are considered to be identical.
Active
If checked, makes the index available for use. You can uncheck this option to temporally deactivate the index.
Sorting
Sorts columns in ascending/descending order, the default order if none is specified.
Update selectivity
Check this box to recompute the selectivity of the index. You can also perform this action using the popup menu from the Indexes tab.