在分析SQL性能的时候,经常需要确定资源消耗多的SQL,总结如下:
1 查看值得怀疑的SQL
select substr(to_char(s.pct,'99.00'),2)||'%'load,
s.executions executes,
p.sql_text
from(select address,
disk_reads,
executions,
pct,
rank() over(order by disk_reads desc) ranking
from(select address,
disk_reads,
executions,
100*ratio_to_report(disk_reads) over() pct
from sys.v_$sql
where command_type!=47)
where disk_reads>50*executions) s,
sys.v_$sqltext p
where s.ranking10000
order by disk_reads desc;
3 查看逻辑读多的SQL
select*
from(select buffer_gets, sql_text
from v$sqlarea
where buffer_gets>500000
order by buffer_gets desc)
where rownum