oracle高资源消耗sql,oracle 耗资源比较大的SQL

时间:

select sql_id,sid,serial#,username,target ,sql_plan_operation,sofar blocks_read,totalwork total_blocks,round(time_remaining/60) minutes from v$session_longops

where sofar<>totalwork

and username='XXX'

sofar : Units of work done so far for the operation specified in the OPNAME column

这个值会一直增加,就是截止到目前所统计出的工作总量,而这里用了where sofar<>totalwork的含义代表就是此事务还没结束,因为结束了sofar会等于totalwork.

Totalwork:Total units of work for the operation specified in the OPNAME column

预估出的总数据块读取量,不会改变

Time_remaining:Estimate (in seconds) of time remaining for the operation to complete

V$SESSION_LONGOPS displays the status of various operations that run for longer than 6 seconds (in absolute time). These operations currently include many backup and recovery functions, statistics gathering, and query execution, and more operations are added for every Oracle release.

官方文档并未对v$session_longops原理做详细的介绍,想要通过v$session_longops监控一个操作,需要满足以下条件:

1 执行操作超过6秒

2 执行操作访问数据块必须大于10000

3 必须设置了TIMED_STATISTICS或者打开了SQL_TRACE

4 执行操作中的对应必须通过DBMS_STATS或ANALYZE进行了分析

在以上基础上再关联v$sql.

IO

select sql_id,disk_reads from

(select sql_id,buffer_gets,disk_reads,sorts,cpu_time/1000000 cpu,rows_processed,elapsed_time from v$sqlstats

order by disk_reads desc

--- 具体要依据什么信息排序可适当选择,而此视图里的多项值是累积的

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值