调整数据字典高速缓存(Dictionary Cache)
数据字典高速缓存包括了有关数据库的结构、用户、实体信息等。数据字典的命中率对系统有很大的影响。命中率的计算中,getmisses 表示失败次数,gets表示成功次数。
查询V$ROWCACHE表:
SQL> select (1-sum(getmisses)/(sum(gets)+sum(getmisses)))*100 from v$rowcache;
or
select (sum(gets - getmisses - usage - fixed)) / sum(gets) "ROW CACHE" from v$rowcache;
dictionary cache hit ratio > 95%
如果该值>90%,说明命中率合适。否则,应增大共享池的大小。
避免出现Dictionary cache的misses,或者misses的数量保持稳定,只能通过调整shared_pool_size来间接调整dictionary cache的大小。
Percent misses应该很低:大部分应该低于2%,合计应该低于15%
select sum(getmisses)/sum(gets) from v$rowcache;
若超过15%,增加shared_pool_size的值。
调整数据库缓冲区高速缓存, Oracle 在运行期间向数据库高速缓存读写数据,高速缓存命中表示信息已在内存中,高速缓存失败意味着ORACLE必需进行磁盘I/O。保持高速缓存失败率最小的关键是确保高速缓存的大小。初始化参数db_block_buffers控制数据库缓冲区高速缓存的大小。可通过查询V$SYSSTAT命中率,以确定是否应当增加db_block_buffers的值。
SQL> select name,value from v$sysstat where name in ('dbblock gets','consistent gets','physical reads');
通过查询结果
命中率=1-physical reads/( db block gets +consistent gets)
如果命中率<0.6~0.7,则应增大db_block_buffers。
1)granule大小的设置,db_cache_size以字节为单位定义了default buffer pool的大小。
如果SGA<128M,granule=4M,否则granule=16M,即需要调整sga的时候以granule为单位增加大小,并且sga的大小应该是granule的整数倍。
2) 根据v$db_cache_advice调整buffer cache的大小
select size_for_estimate,buffers_for_estimate,estd_physical_read_factor,estd_physical_reads
from v$db_cache_advice
where name='DEFAULT' AND advice_status='ON' AND block_size=
(select value from v$parameter where name ='db_block_size')
estd_physical_read_factor<=1
3) 统计buffer cache的cache hit ratio>90%,如果低于90%,可以用下列方案解决:
增加buffer cache的值;
使用多个buffer pool;
Cache table;
为 sorting and parallel reads 建独立的buffer cache;
select name,value
from v$sysstat
where name in('session logical reads','physical reads','physical reads direct','physical reads direct(lob)');
Cache hit ratio=1-(physical reads-physical reads direct-physical reads direct (lob))/session logical reads;  
select 1-(phy.value-dir.value-lob.value)/log.value
from v$sysstat log,v$sysstat phy,v$sysstat dir,v$sysstat lob
where log.name='session logical reads' and phy.name='physical reads' and dir.name='physical reads direct' and lob.name='physical reads direct(lob)';
影响cache hit ratio的因素: 全表扫描;应用设计;大表的随机访问;cache hits的不均衡分布;
4)表空间使用自动空间管理,消除了自由空间列表的需求,可以减少数据库的竞争