Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1185020
  • 博文数量: 398
  • 博客积分: 10110
  • 博客等级: 上将
  • 技术积分: 4055
  • 用 户 组: 普通用户
  • 注册时间: 2007-12-23 20:01
个人简介

新博客http://www.cnblogs.com/zhjh256 欢迎访问

文章分类

全部博文(398)

文章存档

2012年(1)

2011年(41)

2010年(16)

2009年(98)

2008年(142)

2007年(100)

我的朋友

分类:

2007-12-25 22:03:32

如何计算缓存命中率
    缓存命中率通常是由记录在V$SYSSTAT视图中的以下三个统计计算的:
    ·consistent gets:当块在一致性模式下被请求时,如果在请求的语句/事务开始后任何改变被提交或者对该块进行了改变,那么为了读取
它们必须回滚,以得到一致性视图。
     需要注意的是:由于Oracle bug的存在,consistent gets统计报告的值实际上严重超过了consistent gets的值,由于这个原因,最好使
用'no work - consistent read gets','cleanouts only - consistent read gets','rollbacks only - consistent read gets','cleanouts
and rollbacks - consistent read gets'的和。
     如下:
SQL> SELECT * FROM V$SYSSTAT WHERE NAME IN ('no work - consistent read gets','cleanouts only - consistent read
gets','rollbacks only - consistent read gets','cleanouts and rollbacks - consistent read gets','consistent gets');
STATISTIC# NAME                                                                  CLASS      VALUE    STAT_ID
---------- ---------------------------------------------------------------- ---------- ---------- ----------
        44 consistent gets                                                           8   37422921 4162191256
       177 no work - consistent read gets                                          128   25977328 2814375799
       178 cleanouts only - consistent read gets                                   128      17284 2904875805
       179 rollbacks only - consistent read gets                                   128       2422 3133064500
       180 cleanouts and rollbacks - consistent read gets                          128         99 1083903169
    ·db block gets:当前模式请求的块数,为了改变,块必须通过当前模式请求得到。某些类型的块,如段头块通常以该模式请求。
    ·physical reads:该值通常大于实际值,因为存在多块读和os缓存。
    一致性读和db块读称为逻辑读。
 
直接读
    85%的命中率不等于15%的未命中率。Oracle直接上在某些操作上执行直接读。因此有可能有85%的命中率,1%的未命中率,剩余14%为直接读。
    直接读在并行扫描和读取临时表空间时使用。块被直接读入pga中的私有缓冲,而不是sga的数据库缓冲缓存。因为块在读取时不搜索缓存
,因此没有命中率。而且随后也没有命中率,因为块在使用完后就被抛弃。事实上,直接读提高了缓存命中率,同时他们通过减少buffer cache latch的大量负载提高了块访问并行性。
    注:可以通过_serial_direct_read参数为串行扫描设置直接读。
 
可以使用一下方法计算缓存命中率
    通常单独计算每个池的命中率比整个数据库缓冲缓存的命中率更有意义。
V$BUFFER_POOL_STATISTICS
或者:
select
  p.bp_name  buffer_pool,
  decode(sum(s.pread),
    0, ' not used',
    to_char(
      100 * sum(s.pread) /
      decode(sum(s.dbbget + s.conget), 0, 1, sum(s.dbbget + s.conget)),
      '9990.00'
    ) || '%'--排斥直接读未命中率
  )  miss_rate
from
  sys.x$kcbwds s,
  sys.x$kcbwbpd p
where
  s.inst_id = userenv('Instance') and
  p.inst_id = userenv('Instance') and
  s.set_id >= p.bp_lo_sid and
  s.set_id <= p.bp_hi_sid and
  p.bp_size != 0
group by
  p.bp_name
阅读(2859) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~