select round(100 * a.pct, 2) "消耗时间占比",
round(a.elapsed_time/1000000, 2) "总消耗时间",
round(a.elapsed_time/a.executions/1000000) "每次执行每次消耗时间",
round(a.cpu_time/1000000, 2) "CPU使用时间",
a.buffer_gets "读缓存区总次数",
round(a.buffer_gets/a.executions) "每次执行读缓存区次数",
a.executions "执行次数",
a.rows_processed "影响列数",
s.sql_text "sql语句"
from (select *
from (select elapsed_time, -- 解析/执行/取得等消耗时间(单位,毫秒)
ratio_to_report(elapsed_time) over () pct, -- 占比
cpu_time, -- 解析/执行/取得等CPU使用时间(单位,毫秒)
buffer_gets, -- 读缓存区次数
executions, -- 自它被载入缓存库后的执行次数
rows_processed, -- 解析SQL语句返回的总列数
address, -- 当前游标父句柄地址
hash_value -- 缓存库中父语句的Hash值
from v$sql
where LAST_ACTIVE_TIME>= to_date('2019-04-16 10:00:00','yyyy-mm-dd hh24:mi:ss')
and LAST_ACTIVE_TIME<= to_date('2019-04-16 16:00:00','yyyy-mm-dd hh24:mi:ss')
order by elapsed_time desc)
where rownum < 26) a,
v$sqlarea s
where a.address = s.address
and a.hash_value = s.hash_value
and a.executions <> 0
order by 消耗时间占比 desc, CPU使用时间 desc;
Oracle特定时间内数据库执行时间最长的SQL
最新推荐文章于 2024-08-04 16:47:43 发布