最耗资源的10条sql

 ----当前最耗资源的10个cpu

 

select * from (select address,hash_value,
round(cpu_time/1000000) cpu_time_s,
round(cpu_time/decode(executions,0,1,executions)/1000000,2) cpu_time_per,
executions,
SQL_TEXT
from v$sqlarea
order by cpu_time_s desc)
where rownum <= 10;

 

 

 ----当前最耗资源的10个cpu

select * from (select A.ADDRESS,A.hash_value,B.sid,p.SPID,
round (A.CPU_TIME /1000000) cpu_time_s,
round(A.cpu_time/decode(executions,0,1,executions)/1000000,2) cpu_time_per,
A.executions,
A.SQL_TEXT
from V$SQLAREA A, V$SESSION B, V$PROCESS P
WHERE B.SQL_HASH_VALUE = A.HASH_VALUE
AND P.ADDR = B.PADDR
order by cpu_time_s desc)
where rownum <= 10;

 

---历史分析sql_id

set lines 155
col execs for 999,999,999
col avg_etime for 999,999.999
col avg_lio for 999,999,999.9
col begin_interval_time for a30
col node for 99999
break on plan_hash_value on startup_time skip 1
select ss.snap_id, ss.instance_number node, begin_interval_time, sql_id, plan_hash_value,
nvl(executions_delta,0) execs,
(elapsed_time_delta/decode(nvl(executions_delta,0),0,1,executions_delta))/1000000 avg_etime,
(buffer_gets_delta/decode(nvl(buffer_gets_delta,0),0,1,executions_delta)) avg_lio
from DBA_HIST_SQLSTAT S, DBA_HIST_SNAPSHOT SS
where sql_id = nvl('&sql_id','4dqs2k5tynk61')
and ss.snap_id = S.snap_id
and ss.instance_number = S.instance_number
and executions_delta > 0
order by 1, 2, 3
/

 

转载于:https://www.cnblogs.com/feiyun8616/p/7815633.html

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值