1、查看大小
SQL> show parameter db_cache_size;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_cache_size big integer 96M
2、查看缓冲区命中率是否需要调优
SQL>
select 1 - ((physical.value - direct.value - lobs.value) / logical.value)
"Buffer Cache Hit Ratio"
from v$sysstat physical,v$sysstat direct,v$sysstat lobs,v$sysstat logical
where physical.name = 'physical reads'
and direct.name='physical reads direct'
and lobs.name='physical reads direct (lob)'
and logical.name='session logical reads';
Buffer Cache Hit Ratio
----------------------
.906437759
3、获取推荐值
select name,size_for_estimate,v$db_cache_advice.ESTD_PHYSICAL_READS from v$db_cache_advice where block_size='8192' and advice_status='ON';
NAME SIZE_FOR_ESTIMATE ESTD_PHYSICAL_READS
-------------------- ----------------- -------------------
DEFAULT 24 5463
DEFAULT 48 5269
DEFAULT 72 5269
DEFAULT 96 5269
DEFAULT 120 5269
DEFAULT 144 5269
DEFAULT 168 5269
DEFAULT 192 5269
DEFAULT 216 5269
DEFAULT 240 5269
DEFAULT 264 5269
DEFAULT 288 5269
DEFAULT 312 5269
DEFAULT 336 5269
DEFAULT 360 5269
DEFAULT 384 5269
DEFAULT 408 5269
DEFAULT 432 5269
DEFAULT 456 5269
DEFAULT 480 5269
20 rows selected.
set linesize 1000
select size_for_estimate, buffers_for_estimate ,ESTD_PHYSICAL_READ_factor,ESTD_PHYSICAL_READS from v$db_cache_advice
where block_size='8192' and advice_status='ON';
SIZE_FOR_ESTIMATE BUFFERS_FOR_ESTIMATE ESTD_PHYSICAL_READ_FACTOR ESTD_PHYSICAL_READS
----------------- -------------------- ------------------------- -------------------
24 2946 1.1993 9790
48 5892 1 8163
72 8838 1 8163
96 11784 1 8163
120 14730 1 8163
144 17676 1 8163
168 20622 1 8163
192 23568 1 8163
216 26514 1 8163
240 29460 1 8163
264 32406 1 8163
288 35352 1 8163
312 38298 1 8163
336 41244 1 8163
360 44190 1 8163
384 47136 1 8163
408 50082 1 8163
432 53028 1 8163
456 55974 1 8163
480 58920 1 8163
20 rows selected.
可以发现当SIZE_FOR_ESTIMATE = 48M 之后 ESTD_PHYSICAL_READS固定不再发生变化
所以我们设置DB_CHACHE_SIZE的值为48M
4、修改DB_CHACHE_SIZE为48M
SQL> alter system set db_cache_size=48M;
System altered.
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup;
ORACLE instance started.
Total System Global Area 780824576 bytes
Fixed Size 2232432 bytes
Variable Size 499126160 bytes
Database Buffers 276824064 bytes
Redo Buffers 2641920 bytes
Database mounted.
Database opened.
再查看
select 1 - ((physical.value - direct.value - lobs.value) / logical.value)
"Buffer Cache Hit Ratio"
from v$sysstat physical,v$sysstat direct,v$sysstat lobs,v$sysstat logical
where physical.name = 'physical reads'
and direct.name='physical reads direct'
and lobs.name='physical reads direct (lob)'
7 and logical.name='session logical reads';
Buffer Cache Hit Ratio
----------------------
.936568475
如果修改大小时遇到sga空间不足,适当修改SGA大小之后再改DB_CACHE_SIZE大小