Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Stored outlines Plans Not getting used...

Re: Stored outlines Plans Not getting used...

From: RaviAlluru <ravi.alluru_at_gmail.com>
Date: 21 Nov 2005 15:43:59 -0800
Message-ID: <1132616639.493200.70500@g49g2000cwa.googlegroups.com>


Thanks Jonathan,

    For your response. This is what I tried...

In a schema "pin144" , with a siumilar structure minus the offending index did the following :

alter session set create_stored_outlines = true

create or replace outline ADM30203
on
select

sum( item_t.due ),
sum( item_t.item_total ), sum( item_t.adjusted ),
sum( item_t.disputed), sum( item_t.recvd ),
sum( item_t.transfered ),
sum( item_t.writeoff )

from item_t
where (item_t.ar_account_obj_ID0 = 19556536 and item_t.ar_account_obj_DB = 9 )
and (item_t.ar_bill_obj_ID0 = 0 and item_t.ar_bill_obj_DB = 0 ) and ( item_t.poid_type not in
 ( '/item/payment', '/item/payment/reversal', '/item/refund', '/item/adjustment', '/item/dispute',
  '/item/settlement', '/item/writeoff' ) )

Notice the above statment has no hints as you suggested.

alter session set create_stored_outlines = false

select name, category, used, sql_text
from USER_outLines

ADM30203 DEFAULT UNUSED is the result.

On this same schema I try ..

alter session set use_storEd_outlines=TRUE

select

sum( item_t.due ),
sum( item_t.item_total ), sum( item_t.adjusted ),
sum( item_t.disputed), sum( item_t.recvd ),
sum( item_t.transfered ),
sum( item_t.writeoff )

from item_t
where (item_t.ar_account_obj_ID0 = 19556536 and item_t.ar_account_obj_DB = 9 )
and (item_t.ar_bill_obj_ID0 = 0 and item_t.ar_bill_obj_DB = 0 ) and ( item_t.poid_type not in
 ( '/item/payment', '/item/payment/reversal', '/item/refund', '/item/adjustment', '/item/dispute',
  '/item/settlement', '/item/writeoff' ) )

The following is the explain plan for the above statement...

Operation Object Name Rows Bytes Cost Object Node In/Out PStart PStop

SELECT STATEMENT Optimizer Mode=CHOOSE 1 2

  SORT AGGREGATE		1  	54
    TABLE ACCESS BY INDEX ROWID	PIN144.ITEM_T	1  	54  	2

      INDEX RANGE SCAN	PIN144.I_ITEM_AR_ACCOUNT_OBJ__ID	187
	1


and when I go back and query the user_outlines table ..

select name, category, used
from USER_outLines

ADM30203 DEFAULT USED is the result.

So all is good up to now.

Next I export the ol$% tables from the outln schema on this instance by doing the following:

It exports the 3 tables ...

exp outln/outln_at_stmaurd2 tables='OL$' 'OL$NODES' 'OL$HINTS' log=outln_stmaurd2.log

and I import this back into the production instance by doing this ...

 imp outln/outln_at_stmaurp2 file=expdat.dmp log=imp_outln_stmaurp2 ignore=y full=y

It imports them without errors...

I log in as outln on my production instance and do the following ...

update ol$hints set user_table_name='PIN203.ITEM_T' where user_table_name='PIN144.ITEM_T'

and

update ol$ set creator='PIN203'

where PIN203 is our PRODUCTION schema and PIN144 is our TEST schema...

Then I log in as PIN203 schema on PRODUCTION and do the following ..

alter session set use_stored_outlines=TRUE

alter session set cursor_sharing=similar

select

sum( item_t.due ),
sum( item_t.item_total ), sum( item_t.adjusted ),
sum( item_t.disputed), sum( item_t.recvd ),
sum( item_t.transfered ),
sum( item_t.writeoff )

from item_t
where (item_t.ar_account_obj_ID0 = 19556536 and item_t.ar_account_obj_DB = 9 )
and (item_t.ar_bill_obj_ID0 = 0 and item_t.ar_bill_obj_DB = 0 ) and ( item_t.poid_type not in ( '/item/payment', '/item/payment/reversal', '/item/refund', '/item/adjustment', '/item/dispute',
  '/item/settlement', '/item/writeoff' ) )

It sill uses the old explain plan ..

Operation Object Name Rows Bytes Cost Object Node In/Out PStart PStop

SELECT STATEMENT Optimizer Mode=CHOOSE 1 3

  SORT AGGREGATE		1  	55
    TABLE ACCESS BY INDEX ROWID	PIN203.ITEM_T	1  	55  	3

      INDEX RANGE SCAN	PIN203.I_ITEM_AR_BILL_OBJ__ID	9  	 	4

whereas it does show

select name, category, used
from USER_outLines

ADM30203 DEFAULT USED is the result. for the above wuery.

So even though now we have a user outline stored in production without the hint and using the proper index, a query with the same sql doesnt use the correct explain plan.

Is there anytrhing else I am missing. An oracle parameter or something that will enable the use of Stored Outlines?

Thanks again.

Ravi

Jonathan Lewis wrote:
> "RaviAlluru" <ravi.alluru_at_gmail.com> wrote in message
> news:1132262255.843344.55710_at_f14g2000cwb.googlegroups.com...
> > Hello All,
> > We are having a problem, in the problem that Stored Outlines are not
> > getting used.
> > We have a query generated from a third party tool, on which we seem to
> > have no control to pass hints. So we decided to embark on Stored
> > Outlines, and were of the opinion that once we create these outlines
> > (with the proper Index hints ), every time a query similar query is
> > executed , the explain plan from the Stored outline should be used. But
> > this doesnt seem to be the case.
> > here is what were are trying :
> >
> > alter session set create_stored_outlines=TRUE
> >
> > alter session SET use_stored_outlines = TRUE
> >
> > create or replace outline ADM30203
> > on
> > select /*+ index(item_t,I_ITEM_AR_ACCOUNT_OBJ__ID) */
> > sum( item_t.due ),
> > sum( item_t.item_total ), sum( item_t.adjusted ),
> > sum( item_t.disputed), sum( item_t.recvd ),
> > sum( item_t.transfered ),
> > sum( item_t.writeoff )
> > from item_t
> > where (item_t.ar_account_obj_ID0 = :1
> > and item_t.ar_account_obj_DB = 9 )
> > and (item_t.ar_bill_obj_ID0 = :2 and item_t.ar_bill_obj_DB = 0 )
> > and ( item_t.poid_type not in
> > ( '/item/payment', '/item/payment/reversal', '/item/refund',
> > '/item/adjustment', '/item/dispute',
> > '/item/settlement', '/item/writeoff' ) )
> >
> > Explain with the hint is :
> > Operation Object Name Rows Bytes Cost Object Node In/Out PStart PStop
> >
> > SELECT STATEMENT Optimizer Mode=CHOOSE 1 10
> >
> > SORT AGGREGATE 1 55
> > TABLE ACCESS BY INDEX ROWID PIN203.ITEM_T 1 55 10
> >
> > INDEX RANGE SCAN PIN203.I_ITEM_AR_ACCOUNT_OBJ__ID 62 4
> >
> >
> >
> > ALTER SESSION SET CREATE_STORED_OUTLINES=FALSE
> >
> > ALTER SESSION SET CURSOR_SHARING=SIMILAR
> >
> > When I do a
> > select * from user_outlines I do get
> >
> > ADM30203 DEFAULT UNUSED
> > 11/17/2005 11:44:36 AM 9.2.0.4.0
> > select /*+ index(ite C742E7CE6FD914CF25C1732AF19118AA
> >
> > But when I do try and execute a query with the following enabled:
> >
> > alter session SET use_stored_outlines = TRUE
> >
> > ALTER SESSION SET CURSOR_SHARING=SIMILAR
> >
> >
> > select
> > sum( item_t.due ),
> > sum( item_t.item_total ), sum( item_t.adjusted ),
> > sum( item_t.disputed), sum( item_t.recvd ),
> > sum( item_t.transfered ),
> > sum( item_t.writeoff )
> > from item_t
> > where (item_t.ar_account_obj_ID0 = 19556536
> > and item_t.ar_account_obj_DB = 9 )
> > and (item_t.ar_bill_obj_ID0 = 0 and item_t.ar_bill_obj_DB = 0 )
> > and ( item_t.poid_type not in
> > ( '/item/payment', '/item/payment/reversal', '/item/refund',
> > '/item/adjustment', '/item/dispute',
> > '/item/settlement', '/item/writeoff' ) )
> >
> >
> > I get the following explain plan and the query is slower as expected ,
> > as it doesnt use the same plan as the one in the stored outline.
> >
> > Operation Object Name Rows Bytes Cost Object Node In/Out PStart PStop
> >
> > SELECT STATEMENT Optimizer Mode=CHOOSE 1 3
> >
> > SORT AGGREGATE 1 55
> > TABLE ACCESS BY INDEX ROWID PIN203.ITEM_T 1 55 3
> >
> > INDEX RANGE SCAN PIN203.I_ITEM_AR_BILL_OBJ__ID 9 4
> >
> >
> >
> > If I look at the USED column in the USER_OUTLINES view it still shows
> > up as being UNUSED.
> >
> > My question is how do we force all similar queries, to use the PLAN
> > from the STORED OUTLINE ?
> >
> > Am I missing something?
> >
> >
> > Any help is greatly appreciated.
> >
> > Thanks
> >
> > Ravi Alluru
> >

>
>

> You've created an outline on a piece of text
> that includes the string
> '/*+ index(item_t,I_ITEM_AR_ACCOUNT_OBJ__ID) */'
> when you run the statement that does NOT
> include this string, Oracle CANNOT match
> the strings.
>

> You stored text has to be a very close text match
> for the string that arrives from the application; the
> only variations allowed are in case and spaces.
>

> Unless you are licensed to use the outline manager,
> you have to do something like the following:
>

> capture the outline for the actual SQL
>
> create a schema that holds tables and indexes
> of the same names, and only the indexes you
> want used
>
> Fake some data and/or stats into the schema
> so that the plan you want on production is the
> plan that happens automatically on the fake schema
>
> recompile the stored outline from within that schema.
>

> Now, when you use stored outlines, the original SQL,
> when run against the production schema, will use the
> plan you have just regenerated.
>

> There are a couple of articles on my website about
> stored outlines that you might want to check - but
> the above is the basic requirement.
>
>
>

> --
> Regards
>

> Jonathan Lewis
>

> http://www.jlcomp.demon.co.uk/faq/ind_faq.html
> The Co-operative Oracle Users' FAQ
>

> http://www.jlcomp.demon.co.uk/cbo_book/ind_book.html
> Cost Based Oracle: Fundamentals
>

> http://www.jlcomp.demon.co.uk/appearances.html
> Public Appearances - schedule updated 4th Nov 2005
Received on Mon Nov 21 2005 - 17:43:59 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US