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: Really slow query .. is there a better approach??

Re: Really slow query .. is there a better approach??

From: DA Morgan <damorgan_at_psoug.org>
Date: Sun, 16 Sep 2007 09:59:04 -0700
Message-ID: <1189961935.812841@bubbleator.drizzle.com>


jobs wrote:
> select p.phone,p.account_number,o.amount from users_phones p, orders
> o
> where p.account_number = o.account_number and p.status=1 and p.eci=0
> and o.validation_date > sysdate-15
> and p.btn=1 and o.status=1 and o.id =(select min(oo.id) from orders
> oo
> where oo.ACCOUNT_NUMBER=p.account_number and oo.amount>0 and
> oo.validation_date > sysdate-15)
>
>
> if I run the code up to the "and o.id" It selects 54 rows really fast.
>
> The orders table should only have about 10 to 20 orders per Id. So why
> dos the addition of that min(oo.id) code significantly slow me down.
>
> Is there a better approach.
>
> Thanks in advance for any help or information!

Oracle version number?
Explain plan run with DBMS_XPLAN?

-- 
Daniel A. Morgan
University of Washington
damorgan_at_x.washington.edu (replace x with u to respond)
Puget Sound Oracle Users Group
www.psoug.org
Received on Sun Sep 16 2007 - 11:59:04 CDT

Original text of this message

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