Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save davidhooey/d67befdcf2fdce351320 to your computer and use it in GitHub Desktop.
Save davidhooey/d67befdcf2fdce351320 to your computer and use it in GitHub Desktop.
Oracle Wait Events for SQL_ID within Specific Time Frame
-- V$ACTIVE_SESSION_HISTORY
select
event,
sum(time_waited) time_waited
from
v$active_session_history
where
sql_id = 'SQL_ID'
and
sample_time between
to_timestamp('START_TIMESTAMP', 'YYYY-MM-DD HH24:MI:SS.FF3') and
to_timestamp('END_TIMESTAMP', 'YYYY-MM-DD HH24:MI:SS.FF3')
group by
event
order by
time_waited desc;
-- DBA_HIST_SESS_HISTORY
select
event,
sum(time_waited) time_waited
from
dba_hist_active_sess_history
where
sql_id = 'SQL_ID'
and
sample_time between
to_timestamp('START_TIMESTAMP', 'YYYY-MM-DD HH24:MI:SS.FF3') and
to_timestamp('END_TIMESTAMP', 'YYYY-MM-DD HH24:MI:SS.FF3')
group by
event
order by
time_waited desc;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment