Skip to content

Instantly share code, notes, and snippets.

@davidhooey
Last active December 2, 2016 16:20
Show Gist options
  • Save davidhooey/6235227 to your computer and use it in GitHub Desktop.
Save davidhooey/6235227 to your computer and use it in GitHub Desktop.
Oracle Elapsed Time Per Execution for SQL
-- Shared Pool
select *
from
(
select
case when executions = 0 then 0
else round(elapsed_time/executions, 3)
end "ElapsedPerExec(ms)",
elapsed_time "ElapsedTime (ms)",
executions "Executions",
sql_id "SQL_ID",
sql_fulltext "SQL_FULLTEXT"
from
v$sql
where
lower(sql_fulltext) like '%some sql search text%'
order by
1 desc
)
where
rownum <= 50
-- AWR
select
sql_id "SQL_ID",
min(snap_id) "MIN_SNAP_ID",
max(snap_id) "MAX_SNAP_ID",
case when sum(executions_delta) = 0 then 0
else round(sum(elapsed_time_delta)/sum(executions_delta), 3)
end "ElapsedPerExec(ms)",
sum(elapsed_time_delta) "ElapsedTime (ms)",
sum(executions_delta) "Executions"
from
dba_hist_sqlstat
where
sql_id = '3sgwcsv5qvfhf'
group by
sql_id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment