今天在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/,如需转载,请注明出处,否则将追究法律责任。