pga/sga及元件值查詢

不一樣的天空w發表於2017-12-14
查詢buffer_cache設定的大小對於物理讀次數和時間的預估影響:
select size_for_estimate         "Cache Size (MB)",
       size_factor,
       buffers_for_estimate      "Buffers",
       estd_physical_read_factor est_read_factor,
       estd_physical_reads       estd_phy_red,
       estd_physical_read_time   est_phy_red_t
  from v$db_cache_advice
 where name = 'DEFAULT'
   and block_size =
       (select value from v$parameter where name = 'db_block_size');


查詢當sga元件大小
SQL> select component,current_size,max_size,min_size from v$sga_dynamic_components;

COMPONENT                                                        CURRENT_SIZE   MAX_SIZE   MIN_SIZE
---------------------------------------------------------------- ------------ ---------- ----------
shared pool                                                        4294967296          0 4294967296
large pool                                                          268435456          0  268435456
java pool                                                           134217728          0  134217728
streams pool                                                        436207616          0  436207616
DEFAULT buffer cache                                               1.6744E+10          0 1.6744E+10
KEEP buffer cache                                                           0          0          0
RECYCLE buffer cache                                                        0          0          0
DEFAULT 2K buffer cache                                                     0          0          0
DEFAULT 4K buffer cache                                                     0          0          0
DEFAULT 8K buffer cache                                                     0          0          0
DEFAULT 16K buffer cache                                                    0          0          0

COMPONENT                                                        CURRENT_SIZE   MAX_SIZE   MIN_SIZE
---------------------------------------------------------------- ------------ ---------- ----------
DEFAULT 32K buffer cache                                                    0          0          0
ASM Buffer Cache                                                            0          0          0

13 rows selected.

SQL>


SQL>  select pool,sum(bytes/1024/1024) size_m from v$sgastat group by pool;

POOL             SIZE_M
------------ ----------
             15983.9976
shared pool  4126.17428
streams pool  416.03157
large pool          256
java pool           128



oracle 提供了多個初始化引數,來設定SGA中各個部分的記憶體大小
SQL> show parameter shared_pool_size;
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
shared_pool_size                     big integer 244M
控制共享池的大小,例項執行期間可以動態調整


SQL> show parameter java_pool_size;
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
java_pool_size                       big integer 52M
 控制JAVA池的大小,例項執行期間可以動態調整


SQL> show parameter large_pool_size;
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
large_pool_size                      big integer 60M
 控制大池的大小,例項執行期間可以動態調整


SQL> show  parameter streams_pool_size;
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
streams_pool_size                    big integer 0
 控制流池的大小,例項執行期間可以動態調整


SQL> show parameter db_cache_size;
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_cache_size                        big integer 160M
控制資料緩衝區的大小,例項執行期間可以動態調整


SQL> show parameter log_buffer;
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
log_buffer                           integer     5603328
 控制日誌緩衝區的大小,該引數在執行期間是不能修改的。


SQL> show parameter sga_target;
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
sga_target                           big integer 0
與SGA的自動管理相關,如果值是零,需要DBA手動管理SGA


SQL> show parameter sga_max_size;
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
sga_max_size                         big integer 524M
sga可以使用的最大記憶體,sga_target的值不能超過sga_max_size,在為SGA中個部分組成 分配記憶體時,SGA的總記憶體不能超過sga_max_size設定的值,否則會報錯。sga_max_size 在例項執行期間不能夠動態調整,必須先修改初始化引數檔案,然後重啟例項。
sga_max_size引數僅在例項執行期間有效,如果例項啟動時發現SGA各部分組成的引數值 總和大於sga_max_size,例項會忽略當前設定的sga_max_size值,並修改sga_max_size為 當前SGA的最大值。
 
SQL> show parameter statistics_level;
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
statistics_level                     string      TYPICAL
 該值與SGA記憶體的自動管理相關,值為typical或者all的時候oracle會根據會更加收集到的相關統計資訊作為參照,確定如何分配SGA中的各部分記憶體。
 
 oracle SGA中的各部分記憶體都是以粒度進行分配與回收。粒度的大小不能由DBA設定,取決與SGA的大小,系統平臺的型別。 在大多數平臺下SGA<1G 粒度是4MB,SGA>1G 粒度是16MB。 在win32平臺下,SGA>1G,粒度是8MB。設定oracle SGA中各部分的值時,需要是oracle 粒度的整倍數,否則oracle會自動進行調整
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
DEFAULT 32K buffer cache                                              4194304
Shared IO Pool                                                        4194304
ASM Buffer Cache                                                      4194304
14 rows selected
oracle SGA中各部分組成粒度值

SQL> select name,bytes from v$sgainfo;
NAME                                  BYTES
-------------------------------- ----------
Fixed SGA Size                      1375820    儲存資料庫與例項的狀態資訊
Redo Buffers                        5795840
Buffer Cache Size                 167772160
Shared Pool Size                  255852544
data dictionary cache              62914560
Java Pool Size                     54525952
Streams Pool Size                         0
Shared IO Pool Size                       0
Granule Size                        4194304
Maximum SGA Size                  548237312
Startup overhead in Shared Pool    58720256
Free SGA Memory Available                 0
SGA中各部分記憶體分配情況檢視
 
SQL> select * from v$sga;
 
NAME                      VALUE
-------------------- ----------
Fixed Size              1375820
Variable Size         373293492 包括共享池,大池,java池,流池幾個組成部分。
Database Buffers      167772160  資料緩衝區(Buffer Cache Size)
Redo Buffers            5795840
SGA中各部分記憶體分配情況檢視。

SGA中各個部分所使用的記憶體只能供自己使用,相互之間無法共享。如果Java Pool分配了1G的記憶體,但是當前資料庫並沒有運用流特性,分配給流池的空間也不能被SGA中的其他
元件使用。所以使用alter system set 設定SGA中各部分組成的記憶體的時候,需要謹慎設定以免導致系統記憶體的浪費,效能損耗。

SQL> show parameter shared_pool_size;
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
shared_pool_size                     big integer 244M
 
SQL> alter system set shared_pool_size=230m;
System altered

SQL> show parameter shared_pool_size;
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
shared_pool_size                     big integer 232M  
 

oracle自動根據粒度調整為粒度(此處是4MB)進行調整。


SQL> show parameter pga

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
pga_aggregate_target                 big integer 4G

SQL> select * from v$pgastat;

NAME                                                                  VALUE UNIT
---------------------------------------------------------------- ---------- ------------
aggregate PGA target parameter                                   4294967296 bytes
aggregate PGA auto target                                        2837357568 bytes
global memory bound                                               429496320 bytes
total PGA inuse                                                  1607690240 bytes
total PGA allocated                                              2188926976 bytes
maximum PGA allocated                                            1.0088E+10 bytes
total freeable PGA memory                                         176619520 bytes
process count                                                           336
max processes count                                                    1115
PGA memory freed back to OS                                      7.4384E+13 bytes
total PGA used for auto workareas                                 464832512 bytes

NAME                                                                  VALUE UNIT
---------------------------------------------------------------- ---------- ------------
maximum PGA used for auto workareas                              5814672384 bytes
total PGA used for manual workareas                                       0 bytes
maximum PGA used for manual workareas                               1062912 bytes
over allocation count                                                 82922
bytes processed                                                  3.2595E+14 bytes
extra bytes read/written                                         4.6775E+12 bytes
cache hit percentage                                                  98.58 percent
recompute count (total)                                            15634412

19 rows selected.

SQL>

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

相關文章