Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> tuning sql query to use index
List,
I am tuning a sql query, where I would like to force the optimizer
to use the index.
However not all the columns in the where clause are indexed. (all but 1)
eg.
query
SELECT SLS_ORG_CHILD,SLS_PRD_CHILD,SLS_AMOUNT AMOUNT,SLS_UNITS UNITS
FROM SLSTH3EE
WHERE SLS_PRD_CHILD = :b1
AND SLS_YEAR = :b1 AND SLS_PERIOD = :b2 AND SLS_WEEK = :b3
Index in order of creation
SLSTH3EEP1 columns
- SLS_PRD_CHILD
- SLS_ORG_CHILD
- SLS_YEAR
- SLS_PERIOD
- SLS_WEEK
As you can see the column SLS_ORG_CHILD is not referenced in the where
clause.
I have used an INDEX HINT to force the optimizer to use the index however
the optimizer still favours a Full Table Scan.
There above query should account for about 5% of the total rows from the
SLSTH3EE table.
The execution plan for the above query.
Query Plan
Thanks and Regards
Suhen
-- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Suhen Pather INET: Suhen.Pather_at_strandbags.com.au Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051 San Diego, California -- Public Internet access / Mailing Lists -------------------------------------------------------------------- To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).Received on Wed Jul 11 2001 - 02:25:35 CDT
![]() |
![]() |