关于SGA中的granule size

1、什么是granule?

granule直译为颗粒,ORACLE为SGA 中的组件(eg:log buffer/db buffer/large pool等)分配的最小单元为一个granule. 所以Oracle SGA 的大小总是granule 的整数倍

2、granule在SGA组件的内存分配中是怎么应用的?

就是说,如果:

granule size 为4M,假定我们设置large pool的大小为9M,实际分配给large pool为3个granule,large pool的大小为12M。

granule size 为8M,假定我们设置large pool的大小为9M,实际分配给large pool为2个granule,large pool的大小为16M。

3、granule size怎么决定?

11g官方的解释:

Memory for the

扫描二维码关注公众号,回复: 4998502 查看本文章

shared pool, large pool, java pool, and buffer cache is allocated in units of granules.

The granule size is 4MB if the SGA size is less than 1GB. If the SGA size is greater than 1GB, the granule size changes to 16MB.

The granule size is calculated and fixed when the instance starts up.

The size does not change during the lifetime of the instance.

The granule size that is currently being used for SGA can be viewed in the view V$SGA_DYNAMIC_COMPONENTS.

The same granule size is used for all dynamic components in the SGA.

由此可见,

Granule Size在实例启动时被计算出来,并且在整个实例生命周期内是不可修改的,除非重启实例。

在11g中,如果sga小于1G,granule size默认设置为4M,如果sga大于1G,granule size为16M。

4、查看和修改granule size的方法。

(1)granule size由隐藏参数_ksmg_granule_size决定。

set lines 200 pages 200 
col name for a30 
col value for a30 
col describ for a50
SELECT x.ksppinm NAME, y.ksppstvl VALUE, x.ksppdesc describ
  FROM SYS.x$ksppi x, SYS.x$ksppcv y
WHERE x.indx = y.indx
  AND x.ksppinm LIKE '%_ksmg_granule_size%';

(2)查看v$sgainfo可以看到当前granule size的大小。

set lines 200 pages 200
col RESIZEABLE for a20  
select name,bytes/1024/1024 MB,RESIZEABLE from v$sgainfo where name='Granule Size';

(3)从v$sga_dynamic_componets视图中获取SGA中各组件的信息。

set lines 200 pages 200
col component for a30 alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss'; select component, CURRENT_SIZE/1024/1024 CUR_MB, granule_size/1024/1024 GRANULE_MB,
min_size/1024/1024 MIN_MB,
max_size/1024/1024 MAX_MB, LAST_OPER_TIME
from v$sga_dynamic_components;

COMPONENT  组件的名称。

CURRENT_SIZE  当前组件的大小。

MIN_SIZE  实例启动以来component最小时候的大小。

MAX_SIZE  实例启动以来component最大时候的大小。

GRANULE_SIZE  granule size的大小。

LAST_OPER_TIME  component大小上次被修改的时间(如果修改过于频繁,建议设置参数固定组件的大小)

(4)通过修改掩藏参数_ksmg_granule_size来修改granule size的大小。

alter system set "_ksmg_granule_size"=8388608 scope=spfile;

重启后生效

猜你喜欢

转载自www.cnblogs.com/nathon-wang/p/10295889.html