The optimizer notes whether an index can be used to evaluate a filter. For this purpose, an indexed column is any single column with an index or the first column named in a composite index. If the values contained in the index are all that is required, the rows are not read. It is faster to omit the page lookups for data pages whenever the database server can read values directly from the index.
The optimizer can choose an index for any one of the following cases:
The database server can locate relevant rows in the table by first finding the row in an appropriate index. If an appropriate index is not available, the database server must scan each table in its entirety.
The database server can use the index to find matching values. The following join expression shows such an example:
WHERE customer.customer_num = orders.customer_num
If rows of customer are read first, values of customer_num can be applied to an index on orders.customer_num.
If all the columns in the clause appear in the required sequence within a single index, the database server can use the index to read the rows in their ordered sequence, thus avoiding a sort.
If all the columns in the clause appear in one index, the database server can read groups with equal keys from the index without requiring additional processing after the rows are retrieved from their tables.