Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Really slow query .. is there a better approach??
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! Received on Sat Sep 15 2007 - 20:53:54 CDT
![]() |
![]() |