Oracle特定时间内数据库执行时间最长的SQL

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;

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值