Home » RDBMS Server » Performance Tuning » Performance tuning of query with self join
Performance tuning of query with self join [message #502358] Wed, 06 April 2011 01:41 Go to next message
preethavinay
Messages: 5
Registered: February 2011
Junior Member
please help me tune the following query:
INSERT  INTO rptkys (rptkyskey,runid,tablename,tableky) 
        (SELECT s_catalog4.nextval,   'R0276518', 'TESTREQ',testreq.testreqkey 
	 FROM    testreq,entorder,patient 
	 WHERE   (testreq.established 
	 BETWEEN '01/01/2010 00:00'  
	 AND     '02/01/2010 00:00' ) 
	 AND      testreq.requesttype = 'C' 
	 AND      entorder.entorderkey = testreq.entorderkey 
	 AND      entorder.patientkey = patient.patientkey 
	 AND      not testreq.status = 'X' 
	 AND      EXISTS (SELECT * from rptkys pssitekeys 
		         WHERE    pssitekeys.runid = 'R0276518' 
                	 AND      pssitekeys.tablename = 'PS_SITE' 
                	 AND      pssitekeys.tableky = testreq.prea_sitekey) 
                	 AND      EXISTS (SELECT * from rptkys pwmethkeys 
					  WHERE   pwmethkeys.runid = 'R0276518' 
					  AND     pwmethkeys.tablename = 'PWMETH' 
					  AND     pwmethkeys.tableky = testreq.prea_pwmethkey) 
  			 AND     1 = pkg_rptpatsec.ps_granted('R0276518' , 'MGR',  NULL,NULL,patient.patseckey) 
                         AND     1 = pkg_rptpatsec.ps_granted('R0276518' , 'MGR', entorder.sfkey,entorder.ptkey)
                         AND     1 = pkg_rptpatsec.ps_granted('R0276518',testreq.testkey,testreq.issecure))

Re: Performance tuning of query with self join [message #502381 is a reply to message #502358] Wed, 06 April 2011 03:00 Go to previous messageGo to next message
cookiemonster
Messages: 13958
Registered: September 2008
Location: Rainy Manchester
Senior Member
Please read the sticky at the top of this forum and post the required information.
And date strings (e.g. '01/01/2010 00:00') should be to_dated with the correct format mask.
Re: Performance tuning of query with self join [message #502444 is a reply to message #502358] Wed, 06 April 2011 06:08 Go to previous message
michael_bialik
Messages: 621
Registered: July 2006
Senior Member
You are using PL/SQL functions, so the performance problem may be caused by some SQL issued by one of these functions.

1. Post TKPROF.
2. What is the relationships between
2.1. testreq and entorder ( 1:1 1:M??)
2.2. entorder and patient?

Previous Topic: how to use index on "ON in MERGE statement"?
Next Topic: Execution plan question
Goto Forum:
  


Current Time: Sun Nov 24 20:44:59 CST 2024