How To Find Execution History Of An sql_id

Hello friends, in this article I'm going to show you how to find execution history of an sql_id.

The below script will display the execution history of a sql_id from AWR. It will join the dba_hist_sqlstat and dba_hist_sqlsnapshot table to get the required information.

select a.instance_number inst_id, a.snap_id,a.plan_hash_value, to_char(begin_interval_time,'dd-mon-yy hh24:mi') btime, abs(extract(minute from (end_interval_time-begin_interval_time)) + extract(hour from (end_interval_time-begin_interval_time))*60 + extract(day from (end_interval_time-begin_interval_time))*24*60) minutes,
executions_delta executions, round(ELAPSED_TIME_delta/1000000/greatest(executions_delta,1),4) "avg duration (sec)" from dba_hist_SQLSTAT a, dba_hist_snapshot b
where sql_id='&sql_id' and a.snap_id=b.snap_id
and a.instance_number=b.instance_number
order by snap_id desc, a.instance_number;
Find Execution History Of An sql_id

Read: ORA 25153 Temporary Tablespace is Empty

2 thoughts on “How To Find Execution History Of An sql_id

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to Top