关于DB_CACHE_SIZE中涉及到的granule size(颗粒值)

来源:互联网 发布:大淘客cms建站要钱吗 编辑:程序博客网 时间:2024/06/11 16:27

在OCP考题中碰到了这样一道题:

You have executed this command to change the size of the database buffer cache:
SQL> ALTER SYSTEM SET DB_CACHE_SIZE=2516582;
System altered.
To verify the change in size, you executed this command:
SQL> SHOW PARAMETER DB_CACHE_SIZE
NAME TYPE VALUE
------------------- ----------- ------------------
db_cache_size big integer 4194304


Why is the value set to 4194304 and not to 2516582?


A.because 4194304 is the granule size
B.because 4194304 is the standard block size
C.because 4194304 is the largest nonstandard block size defined in the database
D.because 4194304 is the total size of data already available in the database buffer cache

找到一篇老盖的文章:http://www.eygle.com/archives/2007/01/oracle_granule_size.html

自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的控制。

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.

ORACLE FAQ:

granule is a unit of contiguous virtual memory allocated to a process.

[edit]Oracle instance

If an Oracle instance starts up, it allocates the SGA (System Global Area) in granule sized memory units. The size of these granules depends on your database version and somtimes even on the operating system port. For example, for Oracle 9i it is typically 4MB if your SGA is smaller than 128MB and 16MB if your SGA is bigger. For later releases it is typically 4MB if your SGA is smaller than 1GB and 16MB if your SGA is bigger. Issue the below query to get your instance's exact granule size:

SQL> SELECT * FROM v$sgainfo WHERE name = 'Granule Size';NAME                                  BYTES RES-------------------------------- ---------- ---Granule Size                        4194304 No

The minimum SGA size is three granules, based on:

  1. One Granule for Fixed SGA (includes redo buffers)
  2. One Granule for Buffer Cache
  3. One Granule for the Shared Pool

Note that Oracle will always round-up memory values to the next granule size. The Buffer Cache, Shared Pool, Large Pool and Java Pool, to name a few, can only grow or shrink based on granule boundaries.