在《深入浅出Oracle》一书的P110页,关于Oracle的Granule我有这样一段描述:
自9i开始,Oracle引入新的初始化参数db_cache_size;该参数定义主Block Size(db_block_size定义的块大小)的default缓冲池的大小;
Db_cache_size最小值为一个粒度(granule)。
粒度(granule):粒度是连续虚拟内存分配的单位,粒度是9i新引入的参数,其大小取决于SGA_MAX_SIZE参数所定义的SGA总的大小
当SGA<128M时,粒度值为4M;
否则粒度值为16M
粒度大小受内部隐含参数_ksmg_granule_size的控制
有朋友在Windows2003上测试得出了不同的结论:
SQL> show sga
Total System Global Area 319888364 bytes
Fixed Size 453612 bytes
Variable Size 310378496 bytes
Database Buffers 8388608 bytes
Redo Buffers 667648 bytes
SQL> set linesize 120
SQL> col name for a30
SQL> col value for a20
SQL> col describ for a60
SQL> SELECT x.ksppinm NAME, y.ksppstvl VALUE, x.ksppdesc describ
2 FROM SYS.x$ksppi x, SYS.x$ksppcv y
3 WHERE x.inst_id = USERENV ('Instance')
4 AND y.inst_id = USERENV ('Instance')
5 AND x.indx = y.indx
6 AND x.ksppinm LIKE '%&par%'
7 /
Enter value for par: _ksmg_granule_size
old 6: AND x.ksppinm LIKE '%&par%'
new 6: AND x.ksppinm LIKE '%_ksmg_granule_size%'
NAME VALUE DESCRIB
------------------------------ -------------------- ---------------------------
_ksmg_granule_size 8388608 granule size in bytes
SQL> alter system set sga_max_size=100M scope=spfile;
System altered.
SQL> startup force
ORACLE instance started.
Total System Global Area 114367248 bytes
Fixed Size 453392 bytes
Variable Size 109051904 bytes
Database Buffers 4194304 bytes
Redo Buffers 667648 bytes
数据库装载完毕。
数据库已经打开。
SQL> SELECT x.ksppinm NAME, y.ksppstvl VALUE, x.ksppdesc describ
2 FROM SYS.x$ksppi x, SYS.x$ksppcv y
3 WHERE x.inst_id = USERENV ('Instance')
4 AND y.inst_id = USERENV ('Instance')
5 AND x.indx = y.indx
6 AND x.ksppinm LIKE '%&par%'
7 /
输入 par 的值: _ksmg_granule_size
原值 6: AND x.ksppinm LIKE '%&par%'
新值 6: AND x.ksppinm LIKE '%_ksmg_granule_size%'
NAME VALUE DESCRIB
------------------------------ -------------------- ----------------------------
_ksmg_granule_size 4194304 granule size in bytes
其实这个granule_size在不同平台、不同版本中,Oracle的设置的缺省值都可能不同,书中提到的是一种通常设置,具体的我们知道了Oracle的内存治理方式就好。
Oracle9i的官方文档如下描述:
Granule size is determined by total SGA size. On most platforms, the size of a granule is 4 MB if the total SGA size is less than 128 MB, and it is 16 MB for larger SGAs. There may be some platform dependency, for example, on 32-bit Windows NT, the granule size is 8 MB for SGAs larger than 128 MB.
Oracle10gR2文档如下描述:
Granule size is determined by total SGA size. On most platforms, the size of a granule is 4 MB if the total SGA size is less than 1 GB, and granule size is 16MB for larger
SGAs. Some platform dependencies arise. For example, on 32-bit Windows, the
granule size is 8 M for SGAs larger than 1 GB.
列举如上,供参考。
-The End-
原文地址:http://www.eygle.com/archives/2007/01/oracle_granule_size.Html