最浪费内存的前10 个语句占所有语句的比例

在没有调整的情况下,大多数系统中10 个最常使用的SQL 语句的访问量占了整个系统中内存读操作
的50%以上。本节测量了最影响性能的代码对整个系统所造成危害的严重性,以百分比表示。
获得这个百分比的脚本
set serverout on
DECLARE
CURSOR c1 is
select buffer_gets
from v$sqlarea
order by buffer_gets DESC;
CURSOR c2 is
select sum(buffer_gets)
from v$sqlarea;
sumof10 NUMBER:=0;
mybg NUMBER;
mytotbg NUMBER;
BEGIN
dbms_output.put_line('Percent');
dbms_output.put_line('-------');
OPEN c1;
FOR i IN 1..10 LOOP
FETCH c1 INTO mybg;
sumof10 := sumof10 + mybg;
END
LOOP;
CLOSE c1;
OPEN c2;
FETCH c2 INTO mytotbg;
CLOSE c2;
dbms_output.put_line(sumof10/mytotbg*100);
END;
/
338
示例输出
percent
-------
44.07087097075974761701818030622745652422
PL/SQL procedure successfully completed.
另一个SQL 语句,但速度更快一点(仅运行于Oracle 9i 和10g 中)
select sum(pct_bufgets) "Percent"
from (select rank() over ( order by buffer_gets desc ) as rank_bufgets,
to_char(100 * ratio_to_report(buffer_gets) over (), '999.99') pct_bufgets
from v$sqlarea )
where rank_bufgets < 11;
Percent
----------
44.03

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/25198367/viewspace-707721/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/25198367/viewspace-707721/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值