Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Query Execution time Is Unpredictable

722259Sep 17 2009 — edited Sep 18 2009
Hello All,
ENVIRONMENT_ :- ORACLE 10g

Basically i m running a very complex query in sql prompt

My query is_
SELECT A.EMPLID, E.EMAIL_ADDR, E.NAME, A.DEPTID, TO_CHAR(H.CMPNY_SENIORITY_DT,'YYYY-MM-DD'), TO_CHAR(H.SERVICE_DT,'YYYY-MM-DD'), TO_CHAR(A.TERMINATION_DT,'YYYY-MM-DD'), A.SUPERVISOR_ID, 'fr', A.P1_REPORT_LOCATION, A.P1_STATUS_CATEGORY, E.EMAIL_ADDR, H.P1_PAYROLL_ID, TO_CHAR(SYSDATE,'YYYY-MM-DD')
FROM PS_JOB A, PS_P1_EMPLTBL_SRCH A1, PS_PER_ORG_ASGN H, PS_PERSONAL_DATA E, PS_P1_PERSTBL_SRCH E1
WHERE A.EMPLID = A1.EMPLID
AND A.EMPL_RCD = A1.EMPL_RCD
AND A1.OPRID = 'xyz'
AND H.EMPLID = A1.EMPLID
AND H.EMPL_RCD = A1.EMPL_RCD
AND E.EMPLID = E1.EMPLID
AND E1.OPRID = 'xyz'
AND ( A.COMPANY = 'abc'
AND A.EFFDT =
(SELECT MAX(A_ED.EFFDT) FROM PS_JOB A_ED
WHERE A.EMPLID = A_ED.EMPLID
AND A.EMPL_RCD = A_ED.EMPL_RCD
AND A_ED.EFFDT <= SYSDATE)
AND A.EFFSEQ =
(SELECT MAX(A_ES.EFFSEQ) FROM PS_JOB A_ES
WHERE A.EMPLID = A_ES.EMPLID
AND A.EMPL_RCD = A_ES.EMPL_RCD
AND A.EFFDT = A_ES.EFFDT)
AND A.EMPLID = H.EMPLID
AND A.EMPL_RCD = H.EMPL_RCD
AND A.EMPLID = E.EMPLID
AND ( A.EMPL_CLASS NOT IN ('M','N','O')
AND NOT ( A.EMPL_CLASS IN ('S','P')
AND A.EMPL_RCD = 0)
AND NOT ( A.EMPL_RCD >= 1
AND A.EMPL_CLASS = 'D')) )

The first time i run this query in sql-prompt it takes around 30-35 mins.
But after an hour or so when i again run the same query(or with slight modifcation like replacing sysdate with sysdate-1) it gives result in 2-3 mins.
When again i run the above query let say after 2 -3 hours it comes with result in 2-3 mins.

Now, the absurd behavior is," The next morning i run this query it again takes 30-35 mins. But after an hour or so running it again takes 2-3 mins".

And this behavior is repeated every day.

I wanna ask is there sumthing like oracle do some extra work like computing and analyzing the tables first time i run the query. And then store the statistics for sum defined time period. And when i run the query again it gives result fast because it finds the stats in its cache.
if so then how can i force oracle to skip such activities...

Thanks
-pradeep
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 16 2009
Added on Sep 17 2009
8 comments
1,196 views