您好,欢迎光临! 请 |

DB_CACHE_SIZE

作者: | 分类:Oracle | Tag: | 评论:3 
字号:T|T

In Oracle Database,the db_cache_size and db_nk_cache_size parameters determine the size of Database Buffer Cache.

Default value If SGA_TARGET is set: If the parameter is not specified, then the default
is 0 (internally determined by the Oracle Database). If the parameter is
specified, then the user-specified value indicates a minimum value for
the memory pool.
If SGA_TARGET is not set, then the default is either 48 MB or 4MB *
number of CPUs * granule size, whichever is greater

Default value of the db_cache-size :If SGA_TARGET is set: If the parameter is not specified, then the default is 0 (internally determined by the Oracle Database). If the parameter is specified, then the user-specified value indicates a minimum value for the memory pool.

If SGA_TARGET is not set, then the default is either 48 MB or 4MB * number of CPUs * granule size, whichever is greater.

DB_CACHE_SIZE specifies the size of the DEFAULT buffer pool for buffers with the primary block size (the block size defined by the DB_BLOCK_SIZE initialization parameter).

The value must be at least 4M * number of cpus * granule size (smaller values are automatically rounded up to this value). A user-specified value larger than this is rounded up to the nearest granule size. A value of zero is illegal because it is needed for the DEFAULT memory pool of the primary block size, which is the block size for the SYSTEM tablespace.

--------------Derived From Oracle 10g References--------------------

DB_CACHE_SIZE 数据缓冲区

SQL> select * from v$version where rownum<=1;
BANNER
—————————————————————-
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 – 64bi
SQL> show parameter db_cache
NAME                                 TYPE        VALUE
———————————— ———– ——————————
db_cache_advice                      string      ON
db_cache_size                        big integer 0

data buffers
8i中是Db_block_buffers(数据块缓冲缓存区Data block buffers cache)*Db_block_size,
9i及以后版本用Db_cache_size来代替这个参数。
10g中,由oracle本身自动管理的,可以不用手工设置。

在内存的配置中把其他参数设置完后,应把能给的都给Data buffers。Oracle在运行期间向数据库高速缓存读写数据,高速缓存命中表示信息已在内存中,高速缓存失败意味着

Oracle必需进行磁盘I/O。保持高速缓存失败率最小的关键是确保高速缓存的大小。Oracle8i中初始化参数Db_block_buffers控制数据库缓冲区高速缓存的大小。

通过查询V$sysstat表,求出命中率,以确定是否应当增加Db_block_buffers的值。
高速缓存命中率=1-physical   reads/(dbblock   gets+consistent   gets)
select 1 – (select value from v$sysstat where name = 'physical reads') /
((select value from v$sysstat where name = 'consistent gets') +
(select value from v$sysstat where name = 'db block gets')) ratio
from dual;
如果该命中率太小,考虑增大数据库缓冲区。

–原始数据查询
SQL> 1  select name,value
2  from v$sysstat
3* where name in ('db block gets','consistent gets','physical reads')
SQL> /

NAME                                                                  VALUE
—————————————————————- ———-
db block gets                                                      49148660
consistent gets                                                  4223352513
physical reads                                                     51914221

–命中率查询
SQL> select 1 – (select value from v$sysstat where name = 'physical reads') /
2         ((select value from v$sysstat where name = 'consistent gets') +
3         (select value from v$sysstat where name = 'db block gets')) ratio
4    from dual;

RATIO
———-
.987851628

Oracle 10g中,与内存相关的参数可以分为两类:
自动调优的SGA参数:包括DB_CACHE_SIZE、SHARED_POOL_SIZE、LARGE_POOL_SIZE和JAVA_POOL_SIZE。
手动SGA参数:包括LOG_BUFFER、STREAMS_POOL、DB_NK_CACHE_SIZE、DB_KEEP_CACHE_SIZE和DB_RECYCLE_CACHE_SIZE。

SQL> show parameter cache_size
NAME                                 TYPE        VALUE
———————————— ———– ——————————
db_16k_cache_size                    big integer 0
db_2k_cache_size                     big integer 0
db_32k_cache_size                    big integer 0
db_4k_cache_size                     big integer 0
db_8k_cache_size                     big integer 0
db_cache_size                        big integer 0
db_keep_cache_size                   big integer 0
db_recycle_cache_size                big integer 0
SQL> show parameter pool
NAME                                 TYPE        VALUE
———————————— ———– ——————————
buffer_pool_keep                     string
buffer_pool_recycle                  string
global_context_pool_size             string
java_pool_size                       big integer 0
large_pool_size                      big integer 0
olap_page_pool_size                  big integer 0
shared_pool_reserved_size            big integer 47815065
shared_pool_size                     big integer 0
streams_pool_size                    big integer 0

Oracle 10g中,任何时候你都能查询V$SGAINFO,来查看SGA的哪些组件的大小可以调整。
使用自动SGA内存管理,参数STATISTICS_LEVEL必须设置为TYPICAL或ALL。如果不支持统计集合,数据库就没有足够的历史信息来确定大小。采用自动SGA内存管理时,确定自动

调整组件大小的主要参数是SGA_TARGET,该参数在数据库运行时动态调整,最大可以达到SGA_MAX_SIZE参数设置的值(默认等于SGA_TARGET,所以如果想增加SGA_TARGET,就必须在

启动数据库实例之前先把SGA_MAX_SIZE设置得大一些)。
数据库会使用SGA_TARGET值,再减去其他手动设置组件的大小(如DB_KEEP_CACHE_SIZE、DB_RECYCLE_CACHE_SIZE),使用计算得到的内存量来设置默认缓冲区池、共享池、大池和

Java池的大小。在运行时,实例会根据需要动态地对这4个内存区分配和撤销内存。如果共享池内存用光了,实例不会向用户返回一个ORA-04031″Unable to allocate N bytes of

shared memory”错误,而是会把缓冲区缓存缩小几MB(一个granule的大小),再相应地增加共享池的大小。
–Granule的大小查询
SQL> select name,bytes from v$sgainfo where name =’Granule Size’;
NAME                                  BYTES
——————————– ———-
Granule Size                       16777216
SQL> select bytes/1024/1024/8 from v$sgainfo where name =’Granule Size’;
BYTES/1024/1024/8
—————–
2
SQL> show parameter db_block_size
NAME                                 TYPE        VALUE
———————————— ———– ——————————
db_block_size                        integer     8192

也就是2048个db_block_size为一个Granule

SQL> show parameter statistics_level
NAME                                 TYPE        VALUE
———————————— ———– ——————————
statistics_level                     string      TYPICAL
SQL> show parameter sga_target
NAME                                 TYPE        VALUE
———————————— ———– ——————————
sga_target                           big integer 1536M
SQL> show parameter sga_max_size
NAME                                 TYPE        VALUE
———————————— ———– ——————————
sga_max_size                         big integer 1536M

V$sysstat

SQL> desc V$sysstat
Name       Type         Nullable Default Comments
———- ———— ——– ——- ——–
STATISTIC# NUMBER       Y
NAME       VARCHAR2(64) Y
CLASS      NUMBER       Y
VALUE      NUMBER       Y
STAT_ID    NUMBER       Y

v$sgainfo

SQL> desc v$sgainfo
名称                                      是否为空? 类型
—————————————– ——– —————–
NAME                                               VARCHAR2(32)
BYTES                                              NUMBER
RESIZEABLE                                         VARCHAR2(3)

SQL> select * from v$sgainfo;
NAME                                  BYTES RES
——————————– ———- —
Fixed SGA Size                      2128760 No
Redo Buffers                        4325376 No
Buffer Cache Size                 721420288 Yes
Shared Pool Size                  838860800 Yes
Large Pool Size                    16777216 Yes
Java Pool Size                     16777216 Yes
Streams Pool Size                         0 Yes
Granule Size                       16777216 No
Maximum SGA Size                 1610612736 No
Startup overhead in Shared Pool    67108864 No
Startup NUMA Shared Pool memory    33554432 No
Free SGA Memory Available                 0

已选择12行。

-----------Derived From http://my.unix-center.net/~Zianed/?p=477------------

顶一下
(0)
100%
踩一下
(0)
100%

原创内容,转载时请保留原文信息:
文章标题:DB_CACHE_SIZE
↑上一篇↑:
↓下一篇↓:

3 篇回应 (访客:3 篇, 博主:0 篇)

  1. 右脑学习 2010-9-06

    学习了!谢谢分享!

    #-49楼
  2. 网上赚钱 2010-26-06

    不错,过来顶一下 ^_^

    #-48楼
  3. Rix Chan 2014-24-03

    select bytes/1024/1024/8 from v$sgainfo where name =’Granule Size’;
    这个中的8是指什么吖?为什么除以8呀?

    #-47楼

插入图片

NOTICE1:请申请gravatar头像,没有头像的评论可能不会被回复|头像相关帮助!