在9i后,SGA的内部组件大小可以动态调整,也可以由数据库自动管理,在设置内存大小的时候,分配的基本单位是粒度(granule)
- granule是一段连续的虚拟内存,大小区域决SGA_MAX_SIZE大小
- SGA_MAX_SIZE小于128M,Granule为4M,否则Granule为16M
- 每个内存组件分配大小必须为Granule的整数倍
- 整个SGA最小不小于3个Granule大小
- 查看granule大小:v$sgainfo
- 如下,因为sga_max_size大小大于128M,所以granule大小为16M
SQL> select name,bytes/1024/1024 MB,resizeable from v$sgainfo;
NAME MB RES
-------------------------------- ---------- ---
Fixed SGA Size 2.14937592 No
Redo Buffers 6.765625 No
Buffer Cache Size 608 Yes
Shared Pool Size 272 Yes
Large Pool Size 32 Yes
Java Pool Size 16 Yes
Streams Pool Size 0 Yes
Shared IO Pool Size 0 Yes
Granule Size 16 No
Maximum SGA Size 1576.91797 No
Startup overhead in Shared Pool 189.55072 No
Free SGA Memory Available 640
12 rows selected.
SQL> show parameter sga_max_size
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
sga_max_size big integer 1584M
再看如下例子:
虽然设置shared_pool_size大小为10M,但是查看是确实16M,那是因为分配内存的基本单位是粒度granule.每个内存组件分配大小必须为granule的整数倍.
SQL> show parameter shared_p;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
shared_pool_reserved_size big integer 10066329
shared_pool_size big integer 0
SQL> alter system set shared_pool_size=10M;
System altered.
SQL> show parameter shared_p;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
shared_pool_reserved_size big integer 10066329
shared_pool_size big integer 16M