oracle 耗资源比较大的SQL
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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
这个值会一直增加
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进行了分析
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
--- 具体要依据什么信息排序可适当选择,而此视图里的多项值是累积的
以上是关于oracle 耗资源比较大的SQL的主要内容,如果未能解决你的问题,请参考以下文章
linux 系统下oracle 10G perl进程cpu占用100% ,这个进程有啥用?能关掉吗?会不会有啥影响?