Previous Topic

Next Topic

SQL SELECT Clause Indexing

You can manipulate the performance of SQL SELECT statements by controlling which table indices are used or excluded.

Exclude Indexes in Select Queries

You can select to exclude particular indexes or all indexes from a table in a SELECT statement, using a query hint. This can be useful when an index slows down query performance.

The syntax is as follows:

SELECT [//&HINT EXCLUDEINDEX tablename.indexname, tablename.*] *

FROM ....

For example:

SELECT //&HINT EXCLUDEINDEX INHEAD.Document

INLINE.*

FROM INHEAD LEFT OUTER JOIN INLINE ON INHEAD.DocumentID = INLINE.DocumentId

The above example will stop the document index on INHEAD from being used, and will stop all indexes on INLINE from being used.

Force Indexes in Select Queries

You can select to use a specific index from a table in a SELECT statement, using a query hint. This can be useful for controlling query performance.

The syntax is as follows:

SELECT [//&HINT FORCEINDEX tablename1.indexname1, tablename2.indexname2] *

FROM ....

If multiple indexes are referenced for a table, only the last one will be used.

For example:

SELECT //&HINT FORCEINDEX INHEAD.Document

INLINE.Document

FROM INHEAD LEFT OUTER JOIN INLINE ON INHEAD.DocumentID = INLINE.DocumentId

The above example will stop the document index on INHEAD from being used, and will stop all indexes on INLINE from being used.

See Also

SQL SELECT Clause

Book Contents

Book Index