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

Home -> Community -> Mailing Lists -> Oracle-L -> RE: ** SQL tuning question

RE: ** SQL tuning question

From: Bobak, Mark <Mark.Bobak_at_il.proquest.com>
Date: Mon, 1 Mar 2004 17:37:56 -0500
Message-ID: <4C9B6FDA0B06FE4DAF5918BBF0AD82CF03B452F4@bosmail00.bos.il.pqe>


Try this instead:
select /*+ ordered use_nl(ro1) use_nl(o) use_nl(c) */ c.cust_name, o.order_number, ro1.related_order_number from rel_orders ro2, rel_orders ro1, order o, customer c

where  c.cust_id = o.cust_id
and    c.cust_type = 'OV'
and    o.order_number = ro1.order_number
and ro1.related_order_number = ro2.related_order_number  and ro2.order_number = :v_order_number  

-----Original Message-----

From: A Joshi [mailto:ajoshi977_at_yahoo.com] Sent: Monday, March 01, 2004 5:33 PM
To: oracle-l_at_freelists.org
Subject: ** SQL tuning question

Hi,
  I have a query joining three tables similar to the following :  

select c.cust_name, o.order_number, ro1.related_order_number from order o, customer c, rel_orders ro1

where  c.cust_id = o.cust_id
and    c.cust_type = 'OV'
and    o.order_number = ro1.order_number
and    ro1.related_order_number in (select ro2.related_order_number from rel_orders ro2
                                   where  ro2.order_number = :v_order_number)
 

Tables order and customer are huge (millions) and rel_orders is very small (hundreads). I would like the optimizer to go to the small table first then get the order_number and go to orders table which has index on order_number and then go to cust table with cust_id(indexed). I tried the hint /*+ ordered (ro2 ro1 o c) */ but it does not help. I even tried to give the index hint for bigger tables but that does not help. it either does full table scan or index_full_scan. I tried several ways of writing the query but it does not help. I tried without the condition : and c.cust_type = 'OV'. No use. Please note that there can be more than one related_order_number for a order_number. Has someone encountered a similar case and can someone help. Thanks.    


Do you Yahoo!?
Get better spam protection with Yahoo! <http://us.rd.yahoo.com/mailtag_us/*http://antispam.yahoo.com/tools> Mail



Please see the official ORACLE-L FAQ: http://www.orafaq.com

To unsubscribe send email to: oracle-l-request_at_freelists.org put 'unsubscribe' in the subject line.
--
Archives are at http://www.freelists.org/archives/oracle-l/
FAQ is at http://www.freelists.org/help/fom-serve/cache/1.html

-----------------------------------------------------------------
Received on Mon Mar 01 2004 - 16:34:48 CST

Original text of this message

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