日期:2014-05-16  浏览次数:20377 次

Oracle:KEEP pool, RECYCLE pool和DEFAULT pool

alter table table_name cache = alter table table_name storage(buffer_pool default)

alter table_name storage(buffer_pool keep)

alter table?table_name nocache?

?

keep?Buffer Pool

??? Keep Buffer Pool 的作用是缓存那些需要经常查询的对象但又容易被默认缓冲区置换出去的对象,按惯例,Keep pool设置为合理的大小,以使其中存储的对象不再age out,也就是查询这个对象的操作不会引起磁盘IO操作,可以极大地提高查询性能。

??? 默认的情况下 db_keep_cache_size=0,未启用,如果想要启用,需要手工设置db_keep_cache_size的值,设置了这个值之后 db_cache_size 会减少。

??? 并不是我们设置了keep pool 之后,热点表就一定能够缓存在 keep pool ,keep pool 同样也是由LRU 链表管理的,当keep pool 不够的时候,最先缓存到 keep pool 的对象会被挤出,不过与default pool 中的 LRU 的管理方式不同,在keep pool 中表永远是从MRU 移动到LRU,不会由于你做了FTS而将表缓存到LRU端,在keep pool中对象永远是先进先出。

??? 10g中SGA自动管理,ORACLE并不会为我们管理keep pool ,ORACLE只会管理default pool。

???查看 keep pool 大小

SQL> select component,current_size from v$sga_dynamic_components
? 2? where component='KEEP buffer cache';

COMPONENT??????????????????????????????????????????????????????? CURRENT_SIZE
---------------------------- ------------
KEEP buffer cache?????????????????????????????????????????????????????????? 0


??手动分配keep pool

SQL> show parameter keep

NAME???????????????????????????????? TYPE??????? VALUE
------------------------------------ ----------- ------------------------------
buffer_pool_keep???????????????????? string
control_file_record_keep_time??????? integer???? 7
db_keep_cache_size?????????????????? big integer 0

SQL> alter system set db_keep_cache_size=10m;

系统已更改。

SQL> show parameter keep

NAME???????????????????????????????? TYPE??????? VALUE
------------------------------------ ----------- ------------------------------
buffer_pool_keep???????????????????? string
control_file_record_keep_time??????? integer???? 7
db_keep_cache_size?????????????????? big integer 16M这里keep pool 16M,可我前面设置命名是10m了?

SQL> select component,current_size from v$sga_dynamic_components where component='KEEP buffer cache';

COMPONENT??????????????????????????????????????????????????????? CURRENT_SIZE
---------------------------- ------------
KEEP buffer cache??????????????????????????????????????????????????? 16777216????
这里keep pool 16M,可我前面设置命名是10m了?


???查看keep pool剩余大小

SQL> select p.name,a.cnum_repl "total buffers",a.anum_repl "free buffers" from x$kcbwds a, v$buffer_pool p
? 2? where a.set_id=p.LO_SETID and???? p.name='KEEP';

NAME???????????????? total buffers free buffers
-------------------- ------------- ------------
KEEP????????????????????????? 1984???????? 1984
?可以看到没有使用过keep 池

???指定table的缓存池

SQL>create table test? as select * from dba_objects;;

Table created.