Previous Topic Next topic Print topic


Overriding the Optimizer

You can force the use of an index for a particular query, or force the system to not use an index.

To force the use of an index, enter an asterisk (*) in parentheses after the name of the indexed column when you construct the query. To force the system to ignore the index, use enter a hyphen (-) in parentheses after the name of the indexed column when you construct the query.

For example, assuming that an index exists on C_NO:

This query uses the C_NO index.

SELECT c_no, o_no, o_date 
    FROM orders 
    WHERE c_no(*)<20 

This query does not use the index.

SELECT c_no, o_no, o_date 
    FROM orders 
    WHERE c_no(-)<20

The (*) and (-) options are valid only for column names that appear in a WHERE clause. You cannot use the (*) and (-) options in GROUP BY, HAVING or ORDER BY clauses.

Previous Topic Next topic Print topic