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 10:21:16 +0200
Message-ID: <ap5m7g$l00$1@ctb-nnrp2.saix.net>


Bruno D. wrote:

> select t1.c1, t2.c2
> from t1, t2
> where c1=c2
> and c2 in (select c3 from t3 where c4 like '%AAA%')
>
> Tips: c1 is indexed, c2 is a primary key.
>
> The sub query brings 14 lines only. In this case, Oracle will NOT use the
> index on t2.
> It will last about 30 seconds.
>
> If I replace the subquery by the 14 values, it works well --> near
> instant.

This is because you are doing away with the sub-select - which shows that the majority of the processing time is spend on running that query on t3.

Also likely implies (looking at there where clause) that it is doing a full table scan of t3 (of which only 14 rows matches the criteria). This means that _all_ the rows in t3 is read to find those 14 matches.

The join between t1 and t2 is not the problem. The select on t3 is.

Kneejerk. Using a LIKE on a column often mean that data normalisation has been ignored. This is Very Bad (tm). I still find it horrendous working with people daily who design, develop and work with databases, who have _no_ idea about 3rd normal form. I hope this is not the case here.

--
Billy
Received on Wed Oct 23 2002 - 03:21:16 CDT

Original text of this message

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