ITPub博客

首页 > Linux操作系统 > Linux操作系统 > Tips--最好不要用v$sysstat中的statistic#列作為where條件

Tips--最好不要用v$sysstat中的statistic#列作為where條件

原创 Linux操作系统 作者:vongates 时间:2019-01-10 15:30:05 0 删除 编辑

今天在dbasupport site中看到如下的一個Calculate buffer cache hit ratio 的scripts就是用statistic#列來作為查詢條件的,因為在不同的oracle版本中statistic#列中同一值代表的含義不同了,所以用它直接得到錯誤的結果。我們最好用v$sysstat中的name列來計算改寫如下:


Description: Calculate buffer cache hit ratio in the database. Make sure it is more than 80 for an oltp environment and 99 is the best value. 原來的sql(8i中可以這樣寫):

select a.value + b.value "logical_reads",
c.value "phys_reads",
round(100 * ((a.value + b.value) - c.value) / (a.value + b.value)) "BUFFER HIT RATIO"
from v$sysstat a, v$sysstat b, v$sysstat c
where a.statistic# = 38
and b.statistic# = 39
and c.statistic# = 40;
改寫后
select a.value + b.value "logical_reads",
c.value "phys_reads",
round(100 * ((a.value + b.value) - c.value) / (a.value + b.value)) "BUFFER HIT RATIO"
from v$sysstat a, v$sysstat b, v$sysstat c
where a.name = 'db block gets'
and b.name = 'consistent gets'
and c.name = 'physical reads';

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

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

注册时间:2018-09-11

  • 博文量
    449
  • 访问量
    320873