ITPub博客

首页 > 数据库 > Oracle > [Oracle Script] Library Cche Hit Ratio

[Oracle Script] Library Cche Hit Ratio

原创 Oracle 作者:tolilong 时间:2017-08-20 10:20:56 0 删除 编辑
SELECT TO_CHAR(SYSDATE, 'yyyy/mm/dd hh24:mi:ss') TIME,
       SUM(reloads) reloads, round(sum(reloads)/sum(pins),4)*100 "Library Cache Reload Ratio",
       SUM(gets) gets, SUM(gethits) gethits, round(sum(gethits)/sum(gets),4)*100 "GetHit Ratio",
       SUM(pins) pins,SUM(pinhits) pinhits , round(sum(pinhits)/sum(pins),4)*100 "PinHit Ratio"
  FROM v$librarycache;    
-----------------------------------------------------------------------------------------------------------------------------------  
TIME                RELOADS       Library Cache Reload Ratio       GETS      GETHITS    GetHit Ratio    PINS         PINHITS    PinHit Ratio
2017/03/02 11:38:12       4050                             0.01    8702998      8624844            99.1    47411158    47311059          99.79

 
 GETS             可以理解为某个object解析的时候查找的次数(解析阶段)
 GETHITS          get命中次数
 GETHITRATIO      这个值等于gethits/gets
 PINS             某个object 解析过后被执行的次数(发生在执行阶段)
 PINHITS          pin命中次数
 PINHITRATIO      这个值等于pinhits/pins
 RELOADS          某个object 解析过后被从新加载的次数(需要从新从磁盘读取object),也就是没有被缓存到library cache中,这个通常由于shared pool 过小
 INVALIDATIONS    某个对象无效,通常由于对象定义被更改,需要从新解析

select sum(sharable_mem) from v$db_object_cache;    #查看当前shared pool使用的大小
------------------------------------------------
SUM(SHARABLE_MEM)
406164568

select * from v$sgastat where name='free memory' and pool='shared pool';   #查看当前剩余shared pool的大小
-----------------------------------------------------------------------
POOL                NAME    BYTES
shared pool     free memory    511748680


长期运行的数据库的 library cache hitratio 最好应该在95%以上,sum(reloads)与sum(pins) 的比值应该小于 1%,
如果pinhitratio 小于90%,或者reload ratio 大于1% ,而且shared pool 的free memory 很小或者为0,
那么可以适当增加shared_pool的大小,检查应用程序代码效率,比如是否使用了绑定变量等等.

当前pinhit ratio 99.79,reloads ratio 0.01, free memory 500多M,够用.

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

请登录后发表评论 登录
全部评论

注册时间:2010-07-13

  • 博文量
    406
  • 访问量
    1208689