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