SQL ordered by CPU Time-AWR

select t.snap_id as snap_id,
       to_char(t.startup_time, 'yyyy-mm-dd hh24:mi:ss') as "SQL第一次执行时间",
       to_char(t.begin_interval_time, 'yyyy-mm-dd hh24:mi:ss') as "快照开始时间",
       to_char(t.end_interval_time, 'yyyy-mm-dd hh24:mi:ss') as "快照结束时间"
  from DBA_HIST_SNAPSHOT t
 order by snap_id desc;
------------------------------------------------------------------------------------------------------------------
select *
  from (select round((t2.cpu_time_delta / 1000000), 2) as "cpu_time(s)",
               t2.executions_delta as "executions",
               round(((t2.cpu_time_delta / 1000000) / t2.executions_delta),
                     2) as "cpu per Exec (s)",
               round((t2.elapsed_time_delta / 1000000), 2) as "elapsed_time(s)",
               round((t2.cpu_time_delta / t2.elapsed_time_delta) * 100, 2) as "%CPU",
               --round(t1.user_io_wait_time / t2.elapsed_time_delta * 100, 2) as "%IO",
               t1.sql_id as sql_id,
               t1.module as "sql module",
               t1.sql_text as sql_text,
               t1.sql_fulltext as sql_fulltext,
               to_char(t3.begin_interval_time, 'yyyy-mm-dd hh24:mi:ss') as "begin time",
               to_char(t3.end_interval_time, 'yyyy-mm-dd hh24:mi:ss') as "end time"
          from v$sqlarea t1, DBA_HIST_SQLSTAT t2, DBA_HIST_SNAPSHOT t3
         where t1.sql_id = t2.sql_id
           and t2.snap_id = t3.snap_id
           and t2.executions_delta is not null
           and t2.executions_delta <> 0
           and t2.elapsed_time_delta is not null
           and t2.elapsed_time_delta <> 0
              -- and t1.parsing_schema_name in ('FASP_PLATFORM')
           and t2.snap_id = &snap_id
         order by t2.cpu_time_delta desc)
 where rownum <= 10;

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29612373/viewspace-2102744/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/29612373/viewspace-2102744/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值