1.摘要
前些天,我们探讨了Oracle - SGA → Data_buffer_cache之default pool:http://blog.csdn.net/together8/article/details/14095795,了解了data_buffer_cache的作用以及LRU算法等,这里我们接着讨论Data_buffer_cache的其他组成部分:keep pool 、 recycle pool 和 db_nk_cache_size
2.keep pool
keep pool作用:将存储在该缓冲的数据一直保存在缓冲中。该缓存不参与ASMM的动态管理,不能自动调整大小,默认未启用,大小为0.手工修改为指定值后,default pool的空间将会被削减。
经常访问的热点表应该专门放入keep pool中,以防止在默认情况下所有对象都是用default pool,一个大对象临时调用default pool,即将其中的真正热点表挤出default pool,从而导致严重的性能损失。
keeppool的工作方式:
与default pool不同,新读入的数据不断以先进先出的方式从LRU表的MRU端移动到LRU端,直到无空闲缓冲时,LRU端的最久未使用数据被调出缓冲。
因keep pool总是将数据放入MRU端,因此表的cache特征对keep pool没有作用。
★ 查看keep pool当前分配的大小
SQL> select component,current_size from v$sga_dynamic_components where component='KEEP buffer cache';
COMPONENT CURRENT_SIZE
---------------------------------------------------------------- ------------
KEEP buffer cache 0(默认为0)
★ 查看当前buffer_pool当前大小
SQL> select name,current_size from v$buffer_pool;
NAME CURRENT_SIZE
-------------------- ------------
DEFAULT 400
★ 修改keep pool为指定大小,再查看buffer_pool大小
SQL> alter system set db_keep_cache_size=10M scope=both;
System altered.
SQL> select component,current_size from v$sga_dynamic_components where component='KEEP buffer cache';
COMPONENT CURRENT_SIZE
---------------------------------------------------------------- ------------
KEEP buffer cache 16777216
SQL> select name,current_size from v$buffer_pool;
NAME CURRENT_SIZE
-------------------- ------------
KEEP 16
DEFAULT 384
【 有没有发现亮点???
为什么我给keep pool的大小明明是10M,但是为什么出现的确实 16M,有没有想到这是为什么??
这个问题的答案在这里:http://blog.csdn.net/together8/article/details/14087985 稍微提示一下:SGA的内存颗粒分配原则。】
是不是发现: 400 = 16(keep pool) + 384 (default pool)
★★ 如何指定对象使用keep pool
SQL> create table ts2(n number) storage(buffer_pool keep);——直接创建一个表使用keep_pool
Table created.
SQL> alter table aaa storage(buffer_pool keep);——修改一个表使之使用keppr_pool
Table altered.
总结: 事实上,keep pool 我们给他一个特殊的称谓:优先池(仔细想想,貌似,这三个字最适合他了,)
关于keep pool我们介绍到此,有问题请留言,接下来我们研究recycle pool
3.recycle pool
recycle pool原理:随时清除存储在其中不再被用户需要的数据,该缓存不参与ASMM的动态管理,不能自动调整大小,默认为启用,手工修改指定值后,default pool空间会被削减,同 keep pool机制差不多。
那么,什么样的表或者对象最适合于放入此pool中呢?
答:不能访问的大对象或者大表应该专门放入recycle pool,以防止一个大对象临时调入default pool,而将其中的真正热点快挤出default pool,带来性能损失。
recycle pool工作方式:
与default pool 和 keep pool都不同,对于recycle pool,先进入缓存的表被保留在recycle pool中,recycle pool满了以后,后进入的数据则不再保存。
★ 查看recycle pool当前分配的大小
SQL> select component,current_size from v$sga_dynamic_components where component='RECYCLE buffer cache';
COMPONENT CURRENT_SIZE
---------------------------------------------------------------- ------------
RECYCLE buffer cache 0
★ 查看当前buffer_pool当前大小
SQL> select name,current_size from v$buffer_pool;
NAME CURRENT_SIZE
-------------------- ------------
DEFAULT 400
★ 修改keep pool为指定大小,再查看buffer_pool大小
SQL> alter system set db_recycle_cache_size=10M scope=both;
System altered.
SQL> select component,current_size from v$sga_dynamic_components where component='KEEP buffer cache';
COMPONENT CURRENT_SIZE
---------------------------------------------------------------- ------------
KEEP buffer cache 16777216
SQL> select name,current_size from v$buffer_pool;
NAME CURRENT_SIZE
-------------------- ------------
KEEP 16
RECYCLE 16
DEFAULT 368
那如何指定对象使用缓冲池呢?和keep pool配置一样,这里不再累赘。
问题:如何将keeppool 和 recycle pool设置成默认值0??
课后回答!见留言
4.db_nk_cache_size
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_block_size integer 8192(8K)
SQL> show parameter db%cache_size;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_16k_cache_size big integer 0
db_2k_cache_size big integer 0
db_32k_cache_size big integer 0
db_4k_cache_size big integer 0
db_8k_cache_size big integer 0
db_cache_size big integer 0
db_keep_cache_size big integer 0
db_recycle_cache_size big integer 0
System altered.
SQL> show parameter db%cache_size;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_16k_cache_size big integer 16M
db_2k_cache_size big integer 0
db_32k_cache_size big integer 0
db_4k_cache_size big integer 0
db_8k_cache_size big integer 0
db_cache_size big integer 0
db_keep_cache_size big integer 0
db_recycle_cache_size big integer 0
NAME CURRENT_SIZE
-------------------- ------------
DEFAULT 368
DEFAULT 16
alter system set db_8k_cache_size=20M
*
ERROR at line 1:
ORA-32017: failure in updating SPFILE
ORA-00380: cannot specify db_8k_cache_size since 8K is the standard block size