Optimizing the query [message #393577] |
Mon, 23 March 2009 07:43 |
user71408
Messages: 585 Registered: November 2007 Location: NE
|
Senior Member |
|
|
Hi All,
I have written a query. But It's taking around 15 minutes. Can you please check the query and Explain plan of the query and give me the solution for optimize the query.
Query :
SELECT *
FROM temp.r_view
WHERE cur IN (SELECT p_id_d
FROM temp.pm
WHERE p_id_h = 'CURRENCY' AND p_txt
= 'EUR')
AND rec_amt >= 10
AND r_view.date_exec >
TO_DATE ((SELECT p_txt
FROM temp.pm
WHERE p_id_h = 'MONETARY'
AND p_id_d = 'LAST_DATE'
AND p_id_t = 'S'),
'DD-MON-YYYY'
)
AND SID NOT IN (
SELECT gl_sid
FROM s_wr.p_smst
WHERE p_gst.p_idc =
(SELECT p_txt
FROM temp.pm
WHERE p_id_h = 'MONETARY'
AND pm_id_d = 'MONETARY_ID'));
OPERATION OPTIONS OBJECT_NAME POSITION
-------------------------- ------------ -------------
SELECT STATEMENT 199600
FILTER 1
HASH JOIN RIGHT SEMI 1
TABLE ACCESS FULL PM 1
VIEW R_VIEW 2
UNION-ALL 1
TABLE ACCESS FULL IN_CUST_TEMP 1
TABLE ACCESS FULL RC_REG_WORK 2
HASH JOIN 3
VIEW V_SQ_1 1
HASH GROUP BY 1
TABLE ACCESS FULL TP_MAIN_WORK 1
TABLE ACCESS FULL TP_MAIN_WORK 2
TABLE ACCESS FULL IN_SS_RELOAD 4
TABLE ACCESS FULL CTF_AORD_WORK 5
TABLE ACCESS FULL MANXA_RELOAD 6
TABLE ACCESS FULL STX_FR_PURSE 7
TABLE ACCESS BY INDEX ROWID PM 2
INDEX RANGE SCAN K_PRM 1
TABLE ACCESS BY INDEX ROWID P_GST 2
INDEX RANGE SCAN ID1_P_GST 1
TABLE ACCESS BY INDEX ROWID PM 1
INDEX RANGE SCAN K_PM 1
Find the explain plan in the attached doc.
thank you,
[Updated on: Mon, 23 March 2009 07:45] Report message to a moderator
|
|
|
|
Re: Optimizing the query [message #393580 is a reply to message #393577] |
Mon, 23 March 2009 07:46 |
ThomasG
Messages: 3212 Registered: April 2005 Location: Heilbronn, Germany
|
Senior Member |
|
|
Since we don't know ANYTHING about how big your tables are and what indexes you have, we can't suggest anything meaningful.
So you have to go and buy faster hardware.
|
|
|
|
|
|
Re: Optimizing the query [message #393799 is a reply to message #393577] |
Tue, 24 March 2009 07:17 |
JRowbottom
Messages: 5933 Registered: June 2006 Location: Sunny North Yorkshire, ho...
|
Senior Member |
|
|
The first thing I'd do would be to use DBMS_STATS to gather statistics on all the tables used in the query.
That way the CBO might be able to make a better execution plan.
|
|
|
|