Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Mailing Lists -> Oracle-L -> Re: Optimizer help, get query to run as good as with RULE hint
Can you clarify what you mean by:
">I find that I cannot specify multiple Index Hints."
Just for the sake of checking a point,
arrange the tables in the from clause
in the order indicated by the RULE path,
viz:
PRCD_INSTRUCTION
PART
PRCD
PRCD_INSTRUCTION_RUNSHEET
STAGE
RECIPE
(NB Your plan seems to have displayed the
odd order switch on table RECIPE due to
v9 table prefetching - which is odd because
I had heard it was a cost-based thing).
Then put in the ORDERED hint, along with a hint for each table to use the index that appears for that table, with a USE_NL hint viz:
/*+
ordered index(part PART_PK) use_nl(part) index(PRCD PRCD_IK03) use_nl(prcd) ... etc ...
This should give you exactly the same access path as the rule path.
Regards
Jonathan Lewis
http://www.jlcomp.demon.co.uk
Coming soon one-day tutorials:
Cost Based Optimisation
Trouble-shooting and Tuning
Indexing Strategies
(see http://www.jlcomp.demon.co.uk/tutorial.html )
____UK_______March 19th
____USA_(FL)_May 2nd
Next Seminar dates:
(see http://www.jlcomp.demon.co.uk/seminar.html )
____USA_(CA, TX)_August
The Co-operative Oracle Users' FAQ
http://www.jlcomp.demon.co.uk/faq/ind_faq.html
-----Original Message-----
To: Multiple recipients of list ORACLE-L <ORACLE-L_at_fatcity.com>
Date: 18 February 2003 04:32
hint
>Mark,
>
>Here's the query in expl_PRCD.sql
>
>delete plan_table where statement_id ='PRCD_H';
>explain plan
>set statement_id='PRCD_H'
>for
>SELECT /*+ CHOOSE */ DISTINCT
>-- SELECT /*+ RULE */ DISTINCT
>-- SELECT /*+ index (prcd_instruction, prcd_instruction_pk) */
DISTINCT
>-- SELECT /*+ index (prcd_instruction_runsheet,
prcd_instruction_runsheet_pk) *T
>-- SELECT /*+ index (part, part_pk) */ DISTINCT
>--SELECT /*+ ordered index (part, part_pk) use_nl (part
prcd_instruction) */ DIT
>-- SELECT /*+ index (stage, stage_pk) */ DISTINCT
>-- SELECT /*+ use_nl (prcd_instruction) */ DISTINCT
>-- SELECT /*+ use_nl (part) */ DISTINCT
>-- SELECT /*+ full(prcd_instruction) parallel(prcd_instruction, 4) */
DISTINCT
> PRCD_INSTRUCTION_RUNSHEET.STAGE_NAME,
> PRCD_INSTRUCTION_RUNSHEET.RECIPE_NAME,
> PRCD_INSTRUCTION_RUNSHEET.RECIPE_ORDER,
> PRCD_INSTRUCTION_RUNSHEET.PRCD_ID,
> PRCD_INSTRUCTION_RUNSHEET.RECIPE_STAGE,
> PRCD_INSTRUCTION_RUNSHEET.INSTRUCTION_NUMBER,
> RECIPE.RECIPE_TITLE,
> PART.PART_NAME,
> RECIPE.EQP_TYPE,
> PRCD_INSTRUCTION_RUNSHEET.STAGE_ORDER,
> STAGE.STAGE_DESC,
> TO_NUMBER (STAGE.MATCH_ORDER),
> DECODE (STAGE.MATCH_ORDER, STAGE.STAGE_SORT_ORDER, 'N', 'Y'),
> PRCD.PRCD_TITLE
>FROM
> PRCD_INSTRUCTION_RUNSHEET,
> RECIPE,
> PART,
> STAGE,
> PRCD,
> PRCD_INSTRUCTION
>WHERE
> ( PART.PART_ID = PRCD_INSTRUCTION.PRCD_ID )
> AND ( STAGE.STAGE_ID = PRCD_INSTRUCTION_RUNSHEET.RECIPE_STAGE )
> AND ( PRCD.PRCD_ID = PRCD_INSTRUCTION_RUNSHEET.PRCD_ID )
> AND ( (RECIPE.RECIPE_NAME = PRCD_INSTRUCTION_RUNSHEET.RECIPE_NAME)
AND (RECI)
> AND ( (PRCD.PRCD_ID LIKE PRCD_INSTRUCTION.CALL_PRCD_NAME || '.%')
AND (PRCD.)
> AND (
> ( PRCD_INSTRUCTION_RUNSHEET.HIERARCHICAL = 'Y' )
> AND ( PRCD.PRCD_ACTIVE_FLAG = 'A' )
> AND ( PART.PART_ACTIVE_FLAG = 'A' )
> AND ( PART.OBSELETE_FLAG <> 'Y' )
> AND PRCD_INSTRUCTION_RUNSHEET.PRCD_ID NOT LIKE 'F-%'
> AND PRCD_INSTRUCTION_RUNSHEET.PRCD_ID NOT LIKE 'L000%'
> AND PRCD_INSTRUCTION_RUNSHEET.PRCD_ID NOT LIKE 'PCW%'
> )
>/
>
>As you can see, I've even tried Index Hints.
>
>The RULE hint gives me the best performance and usage of
>indexes:
>
>Operation Options Object ID PID
Pos
>------------------------- ---------- ---------------------- ---- ----
-- Please see the official ORACLE-L FAQ: http://www.orafaq.net -- Author: Jonathan Lewis INET: jonathan_at_jlcomp.demon.co.uk Fat City Network Services -- 858-538-5051 http://www.fatcity.com San Diego, California -- Mailing list and web hosting services --------------------------------------------------------------------- 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 Feb 19 2003 - 15:05:11 CST