Skip to content

Instantly share code, notes, and snippets.

@glandaverde
Created November 10, 2015 16:54
Show Gist options
  • Save glandaverde/13707d87f8c18d7c069c to your computer and use it in GitHub Desktop.
Save glandaverde/13707d87f8c18d7c069c to your computer and use it in GitHub Desktop.
sql_id_time_waited
SELECT
INST_ID,event,
time_waited "time_waited(s)",
case when time_waited = 0 then
0
else
round(time_waited*100 / sum(time_waited) Over(), 2)
end "percentage"
from
(
SELECT INST_ID,EVENT, SUM(TIME_WAITED) TIME_WAITED
FROM gV$ACTIVE_SESSION_HISTORY
WHERE SQL_ID = 'SQL_ID'
group by INST_ID,event
)
ORDER BY
time_waited desc;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment