zoukankan      html  css  js  c++  java
  • keep buffer cache

        如果某个表是热点表,经常被访问,就应该考虑将其放入 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 owner='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 ,否者就没有作用了 。

      

  • 相关阅读:
    C# 数据库访问
    ArcGIS API For Silverlight使用在线地图的多种方法总结
    Google Map Api 谷歌地图接口整理
    定义函数up(ch),如字符变量ch是小写字母就转换成大写字母并通过up返回,否则字符ch不改变。要求在短小而完全的程序中显示这个程序是怎样被调用的-简单
    编写一个求方程ax^2+bx+c=0的根的程序,用3个函数分别求当b^2-4ac大于零、等于零和小于零时的方程的根。要求从主函数输入a、b、c的值并输出结果-简单
    已知一个string的对象str的内容为“we are here!”, 使用多种方法输出字符“h”-简单
    使用多种方法编写将两个字符串连接在一起的程序-简单
    c++简单函数应用
    编写一个完整的程序,它读入15个float值,用指针把它们存放在一个存储快里,然后输出这些值的和以及最小值
    编写一个为int型变量分配100个整型量空间的程序-简单
  • 原文地址:https://www.cnblogs.com/hehe520/p/6330703.html
Copyright © 2011-2022 走看看