Last active
January 14, 2020 23:45
-
-
Save davidhooey/f2d55d007613ed0c6edfe3e8064426f0 to your computer and use it in GitHub Desktop.
Oracle top historical SQL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select | |
* | |
from | |
( | |
select | |
ss.module, | |
ss.snap_id, | |
ss.sql_id, | |
ss.plan_hash_value, | |
ss.executions_total, | |
case | |
when ss.elapsed_time_total > 0 then | |
ss.elapsed_time_total/1000 | |
else | |
0 | |
end elapsed_time_ms, | |
case | |
when ss.executions_total > 0 then | |
round(ss.elapsed_time_total/nvl(ss.executions_total, 1)/1000, 2) | |
else | |
0 | |
end elapsed_time_per_exec_ms, | |
ss.rows_processed_total, | |
ss.px_servers_execs_total, | |
ss.sorts_total, | |
ss.invalidations_total, | |
ss.parse_calls_total, | |
ss.buffer_gets_total, | |
ss.disk_reads_total, | |
ss.optimizer_mode, | |
ss.sql_profile, | |
to_char(substr(st.sql_text,1,4000)) sql_text | |
from | |
dba_hist_sqlstat ss | |
inner join | |
dba_hist_sqltext st | |
on ss.sql_id = st.sql_id | |
order by | |
elapsed_time_per_exec_ms desc | |
) | |
where | |
rownum <= 50 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment