Skip to Main Content
  • Questions
  • Is it possible to find out the problem SQL in a procedure which was executed days ago

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Joe.

Asked: October 12, 2016 - 9:16 am UTC

Last updated: October 12, 2016 - 11:25 am UTC

Version: 11.2.0.4

Viewed 1000+ times

You Asked

Hi Team,
Our system was written by plenty a lot of procedures, and one of them did not performance well.
This procedure includes tens of SQL statments, suppose that there's only 1 or 2 SQL statements in the procedure caused this problem. I mean, the rotten apple could injure its neighbours, how could I find out which SQL statement(s) is the rotten one.

And please notice that the procedure was executed and finished DAYS AGO, say, 3 days ago. I know I could make a test with 10046 events and find out the problem SQLs of my procedure, but it's not what I said 'DAYS AGO'. In other words, I want to find out which SQL was the trouble-maker for this procedure at that time, rather than in the future.
BTW, I could not find the SQL statements out from AWR, becuase the SQL statements did not elapse long enough to become the TOP SQL.

Any advice is appreciated.

and Connor said...

(If you are licensed for it) check DBA_HIST_ACTIVE_SESS_HISTORY. That is probably your best bet at this stage

Is this answer out of date? If it is, please let us know via a Comment

More to Explore

PL/SQL demos

Check out more PL/SQL tutorials on our LiveSQL tool.

PL/SQL docs

PL/SQL reference manual from the Oracle documentation library