找出占用大量资源的SQL

该语句找出磁盘读大于10000的SQL

col username format a10
col sid format 9999
select b.username,a.disk_reads,a.executions,a.disk_reads/decode(a.executions,0,1,a.executions) rds_ratio,
a.sql_text sql from v$sqlarea a,dba_users b where a.parsing_user_id=b.user_id and b.username<>'SYS' and a.disk_reads>10000
order by a.disk_reads desc;

该语句找出逻辑读超过10000的SQL

col username format a10
col sid format 9999
select b.username,a.buffer_gets,a.executions,a.buffer_gets/decode(a.executions,0,1,a.executions) rds_ratio,
a.sql_text sql from v$sqlarea a,dba_users b where a.parsing_user_id=b.user_id and b.username<>'SYS' and a.disk_reads>10000
order by a.buffer_gets desc;

该语句找出consistent_gets最多的session

select a.username,a.sid,b.block_gets,b.consistent_gets,b.physical_reads,b.block_changes,b.consistent_changes
from v$session a,v$sess_io b where a.sid=b.sid and username is not null order by consistent_gets desc;

该语句找出physical_gets最多的session

select a.username,a.sid,b.block_gets,b.consistent_gets,b.physical_reads,b.block_changes,b.consistent_changes
from v$session a,v$sess_io b where a.sid=b.sid and username is not null order by physical_gets desc;

可以根据实际需要调整阀值

原文地址:https://www.cnblogs.com/hehe520/p/6330639.html