keep buffer cache&recycle pool

 如果某个表是热点表,经常被访问,就应该考虑将其放入 keep buffer cache.防止其被挤出default pool 。从而减少physical read所带来的I/O开销。

默认的情况下 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> alter system set db_keep_cache_size=10m;

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

COMPONENT                                                        CURRENT_SIZE
---------------------------------------------------------------- ------------
KEEP buffer cache                                                    12582912                 这里keep pool 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                          1497         1497   可以看到没有使用过keep 池

    指定table的缓存池

SQL>create table test(a number,b varchar2(100));

Table created.
SQL> alter table test storage(buffer_pool keep);

Table altered.

或者是 create table test(a number ,b varchar2(100)) storage(buffer_pool keep);
SQL> insert into test values(1,'robinson');

1 row created.

SQL> commit;

Commit complete.

SQL> insert into test values(1,'luobingsen');

1 row created.

SQL> commit;

Commit complete.
SQL> /

NAME                 total buffers free buffers
-------------------- ------------- ------------
KEEP                          1497         1492      可以看到使用了5个block

SQL> select table_name,cache,blocks from dba_tables where wner='ROBINSON' and buffer_pool='KEEP';

TABLE_NAME                     CACHE                    BLOCKS
------------------------------ -------------------- ----------
TEST                               N                        5         可以看到这个表的 5个block 全部cache 到 keep pool ,这里的cache 字段表明 这个表 还没有使用 这个命令 alter table  robinson  cache,如果 使用了 alter table robinson cache ,命令,那么 N 将变成Y

总结:如果表经常使用,而且表较小,可以设置 keep pool ,将table 全部 cache 到 keep pool, keep pool 要么 全部 cache 一个table ,要么 不cache ,所以,对于大表来说,如果想要 cache 到 keep pool, 就需要设置 较大的 keep pool ,以容纳 大的 table ,否者就没有作用了 。

 Document上说,对于访问频率不高的大表,可以将其放入 recycle pool ,以防止将 热点表挤出 default pool ,带来的性能损失。

不过 我 对此 有疑问,既然有了 keep pool 可以将 热点表 cache 到 keep  pool 中,另外由于大表的访问频率不高,我们 为某个大表设置了 recycle pool ,那么岂不是 浪费了 很大的 内存空间在SGA中,得不偿失 ,个人 觉得没有必要设置 recycle pool ,仅个人观点,如有 不同意见 欢迎 一起讨论.

     与keep pool 一样,recycle pool 默认的情况下也是没有分配的,如果为recycle pool 设置了值,那么 default pool 会减少 其查看的方式与 keep pool 一样,这里就不写了。


 

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/16978544/viewspace-705710/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/16978544/viewspace-705710/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值