Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Mailing Lists -> Oracle-L -> QRE: Query tuning help needed
Since you have the query, why dont you check and see what
the system is waiting on while it is executing ? Set
a 10046 trace on it and see what kind of hints that gives
you as to why that session is waiting. Probably some SQL
competing for a Oracle Block in memory. Also, execute
a statspack snapshot before, during and after execution.
>From there you can determine how to speed this up.
Oracle Performance Tuning 101 is a source you may be interested in reading. Also, www.hotsos.com should certainly be of interest to all DBAs regarding the 10046 data.
Good Luck!
Mike
-----Original Message-----
[mailto:Ranganath.Krishnaswamy_at_blr.hpsglobal.com]
Sent: Tuesday, April 29, 2003 6:26 AM
To: Multiple recipients of list ORACLE-L
Hi List,
The below query is taking almost 32 minutes to execute. How do I rewrite the query and/or add hints to make it run faster? The SERVICE table has only 5 records and the cartesian product is very much required. The station table has 10145 records, the seg_min_times table has 3375 records and the pry_two_mr_transit has 3046767 records:
INSERT INTO OD_PAIR_ADD_VALUE_TEMP(ORIGIN, DESTINATION, SERVICE,
ADD_ON_MIN, LAST_UPDATED, UPDATED_BY)
SELECT
ORIGIN, DESTINATION, SERVICE_CODE, CASE WHEN SERVICE_CODE = 'X' THEN AVG(SEG_TIME) + 1 WHEN SERVICE_CODE = 'Y' THEN AVG(SEG_TIME) + 2 WHEN SERVICE_CODE = 'Z' THEN AVG(SEG_TIME) + 3 WHEN SERVICE_CODE = 'Q' THEN AVG(SEG_TIME) + 4 END AS ADD_ON_VALUE, SYSDATE, 'SYSTEM' FROM (SELECT META_ROUTING_KEY AS ROUTE_KEY, ST1.STATION_CODE AS ORIGIN, ST2.STATION_CODE AS DESTINATION, SERVICE_CODE, NVL(SUM(CASE WHEN T.TYPE ='OD' THEN (SELECT nvl(sum(OD_TIME_IN_MIN),0)FROM SEG_MIN_TIMES M, STATION ST3, STATION ST4, PRY_TWO_MR_TRANSIT T, SERVICE
WHEN T.TYPE ='OT' THEN (SELECT nvl(sum(OT_TIME_IN_MIN),0)FROM SEG_MIN_TIMES M, STATION ST3, STATION ST4, PRY_TWO_MR_TRANSIT T, SERVICE
WHEN T.TYPE ='TT' THEN (SELECT nvl(sum(TT_TIME_IN_MIN),0)FROM SEG_MIN_TIMES M, STATION ST3, STATION ST4, PRY_TWO_MR_TRANSIT T, SERVICE
WHEN T.TYPE ='TD' THEN (SELECT nvl(sum(TD_TIME_IN_MIN),0)FROM SEG_MIN_TIMES M, STATION ST3, STATION ST4, PRY_TWO_MR_TRANSIT T, SERVICE
END), 0) AS SEG_TIME FROM PRY_TWO_MR_TRANSIT T, STATION ST1, STATION ST2, SERVICE WHERE ST1.STN_KEY = T.ORG_STN_KEY AND ST2.STN_KEY = T.DEST_STN_KEY AND SERVICE_CODE IN ('X','Y','Z','Q') GROUP BY META_ROUTING_KEY, ST1.STATION_CODE, ST2.STATION_CODE,SERVICE_CODE)
Operation Object Name Rows Bytes Cost TQ In/Out PStart PStop
INSERT STATEMENT Hint=CHOOSE
SORT GROUP BY VIEW SORT GROUP BY NESTED LOOPS NESTED LOOPS NESTED LOOPS TABLE ACCESS FULL STATION TABLE ACCESS BY INDEX ROWID PRY_TWO_MR_TRANSIT
INDEX RANGE SCAN I1_PRY_TWO_MR_TRANSIT TABLE ACCESS BY INDEX ROWID STATION INDEX UNIQUE SCAN PK_STATION TABLE ACCESS FULL SERVICE
Can anybody please let me know as to how do I rewrite the query and/or add additional hints so that the performance is improved (typically it should take 10 min. to execute)? Any help in this regard is very much appreciated.
Thanks and Regards,
Ranganath
WARNING: The information in this message is confidential and may be legally privileged. It is intended solely for the addressee. Access to this message by anyone else is unauthorised. If you are not the intended recipient, any disclosure, copying, or distribution of the message, or any action or omission taken by you in reliance on it, is prohibited and may be unlawful. Please immediately contact the sender if you have received this message in error. Thank you.
-- Please see the official ORACLE-L FAQ: http://www.orafaq.net -- Author: Krishnaswamy, Ranganath INET: Ranganath.Krishnaswamy_at_blr.hpsglobal.com Fat City Network Services -- 858-538-5051 http://www.fatcity.com San Diego, California -- Mailing list and web hosting services --------------------------------------------------------------------- To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). -- Please see the official ORACLE-L FAQ: http://www.orafaq.net -- Author: Johnson, Michael INET: Michael.Johnson_at_oln-afmc.af.mil Fat City Network Services -- 858-538-5051 http://www.fatcity.com San Diego, California -- Mailing list and web hosting services --------------------------------------------------------------------- To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).Received on Tue Apr 29 2003 - 16:26:56 CDT