一般在I/O 使用中,为了提高系统处理速度,系统提前将数据读入一块内存区,叫高速缓存,但提前读入的数据未必就是需要的,这就是命中率.。计算公式为
命中率=1-(physical reads/(db blockgets+consistent gets)
其中:
db block gets 数据请求总数
consistent gets 存取所满足要求的请求
physical reads 造成对磁盘上数据文件存取的数据请求总数
还是:------看内存缓冲区使用效率的指数是命中率HITS:
Hits=Logical_reads/(logical_reads+physical_reads)
其中:logical_reads=db_block_gets+consistent_reads
可以调整db_cache_size的大小或起用多个cache_buffer 如:
db_keep_cache_size
db_recycle_cache_size
SGA命中率
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;
SGA中共享缓存的命中率,应该小于1%
select sum(pins) "Total Pins", sum(reloads) "Total Reloads",
sum(reloads)/sum(pins) *100 libcache
from v$librarycache;
select sum(pinhits-reloads)/sum(pins) "hit radio",sum(reloads)/sum(pins) "reload percent"
from v$librarycache;
SGA中重做日志缓存区的命中率,应该小于1%
SELECT name, gets, misses, immediate_gets, immediate_misses,
Decode(gets,0,0,misses/gets*100) ratio1,
Decode(immediate_gets+immediate_misses,0,0,
immediate_misses/(immediate_gets+immediate_misses)*100) ratio2
FROM v$latch WHERE name IN ('redo allocation', 'redo copy');
高速缓存与主存采用全相联地址映象方式,高速缓存的容量为4mb,分为4块,每块1mb,主存容量为256mb。若主存读写时间为30ns,高速缓存的读写时间为3ns,平均读写时间为3.27ns,则高速缓存的命中率是?
命中的话,读写时间为3ns,不命中,读写时间就是33ns,假设命中率是p,
则 3 x p + 33 x (1 - p) = 3.27,可以求出 p = 99.1%
只为分享!!