SGA中各池記憶體分配顆粒大小與SGA_TARGET引數的關係

passion_of_data發表於2011-07-04

      在ORACLE9I中,各個SGA元件必須手動設定大小,從ORACLE10G開始多了另外一種選擇:自動SGA記憶體管理。當ORACLE使用自動SGA記憶體管理時,只需設定SGA_TARGET,其他與SGA相關的引數都不用管,此時資料庫例項會根據需要為各個池動態地分配記憶體。

      不論是使用自動記憶體管理還是手動記憶體管理,都會發現各個池的記憶體以稱之為顆粒(GRANULE,也叫區組)的單位來分配。一個顆粒大小是4M,8M或16M的記憶體區。各池大小是顆粒的倍數。顆粒的大小有SGA大小來確定,通過檢視V$SGA_DYNAMIC_COMPONENTS可以看到SGA的總大小影響顆粒的大小

SQL> show parameter sga_target;

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
sga_target                           big integer 1020M
SQL> select component, granule_size from v$sga_dynamic_components;

COMPONENT                                                        GRANULE_SIZE
---------------------------------------------------------------- ------------
shared pool                                                           4194304
large pool                                                            4194304
java pool                                                             4194304
streams pool                                                          4194304
DEFAULT buffer cache                                                  4194304
KEEP buffer cache                                                     4194304
RECYCLE buffer cache                                                  4194304
DEFAULT 2K buffer cache                                               4194304
DEFAULT 4K buffer cache                                               4194304
DEFAULT 8K buffer cache                                               4194304
DEFAULT 16K buffer cache                                              4194304

COMPONENT                                                        GRANULE_SIZE
---------------------------------------------------------------- ------------
DEFAULT 32K buffer cache                                              4194304
ASM Buffer Cache                                                      4194304

13 rows selected.

SQL> alter system set sga_target=1035m scope=spfile;

System altered.

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.

Total System Global Area 1090519040 bytes
Fixed Size                  2083304 bytes
Variable Size             301991448 bytes
Database Buffers          771751936 bytes
Redo Buffers               14692352 bytes
Database mounted.
Database opened.
SQL> show parameter sga_target

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
sga_target                           big integer 1040M
SQL> select component,granule_size from v$sga_dynamic_components;

COMPONENT                                                        GRANULE_SIZE
---------------------------------------------------------------- ------------
shared pool                                                          16777216
large pool                                                           16777216
java pool                                                            16777216
streams pool                                                         16777216
DEFAULT buffer cache                                                 16777216
KEEP buffer cache                                                    16777216
RECYCLE buffer cache                                                 16777216
DEFAULT 2K buffer cache                                              16777216
DEFAULT 4K buffer cache                                              16777216
DEFAULT 8K buffer cache                                              16777216
DEFAULT 16K buffer cache                                             16777216

COMPONENT                                                        GRANULE_SIZE
---------------------------------------------------------------- ------------
DEFAULT 32K buffer cache                                             16777216
ASM Buffer Cache                                                     16777216

13 rows selected.

以上的例子使用的是自動SGA管理,由以上可以知道,當SGA小於或等於1GB時,顆粒為4M,當SGA大小查過閥值1G時(對於不同的作業系統甚至不停的版本,這個閥值可能稍有變化),可以看到顆粒大小由4M變為16M。

 

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/25964700/viewspace-701289/,如需轉載,請註明出處,否則將追究法律責任。

相關文章