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

Home -> Community -> Usenet -> c.d.o.misc -> Re: Query tuning

Re: Query tuning

From: Billy Verreynne <vslabs_at_onwe.co.za>
Date: Wed, 23 Oct 2002 12:04:32 +0200
Message-ID: <ap5s90$s30$1@ctb-nnrp2.saix.net>


Bruno D. wrote:

> What about this real examples:
>
> select ep.no_emiarte, e.titre_o_prg
> from entete_prog ep, entete e, remontage r
> where ep.no_emiarte=e.no_emiarte
> and ep.no_emiarte=r.no_emiarte
> and ep.remontage=r.remontage
> and ep.no_emiarte in ('002255-000'); ---------------------> 200 ms
>
> select ep.no_emiarte, e.titre_o_prg
> from entete_prog ep, entete e, remontage r
> where ep.no_emiarte=e.no_emiarte
> and ep.no_emiarte=r.no_emiarte
> and ep.remontage=r.remontage
> and ep.no_emiarte in (select '002255-000' from dual); -----> 13 seconds
> !!!!!!!

Interesting..

> In the second case, the 'explain plan' shows that oracle uses index no
> more !!!

Exactly. You have answered your own question. :-)

Obviously the execution plan is different given the significant difference in performance.

The actual question then is why does the Oracle CBO decide to use a different execution plan for these two queries. I believe the answer to that is what the Oracle CBO in your case mistakenly thinks is the cost for the subselect.

A work around can be to do away with the sub-select all together and make it part of the join.

E.g.
select
  t1.c1,
  t2.c2
from t1, t2, t3

where t1.c1 = t2.c2
and   t2.c2 = t3.c3 
and   t3.c3 like '%AAA%'

Other obvious question is if the relevant tables and indexes are analayzed?

--
Billy
Received on Wed Oct 23 2002 - 05:04:32 CDT

Original text of this message

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