Buffer Cache(缓冲区缓存)篇:缓存区块大小

缓冲区缓存(Buffer Cache)

 Buffer Cache是SGA的一部分,保存最近从磁盘读取的或修改的(dml修改或添加)数据块。Buffer Cache的目的就是减少磁盘I/O和构造cr块。

Oracle允许表空间最多使用5种不同的块大小,由db_cache_size和db_nk_cache_size决定。如果一天或一周中事务处理发生了变化,就可以动态的改变db_cache_size和db_nk_cache_size 的值而不必重启实例,以便提高表空间性能。

db_cache_size参数指定默认的buffer pool的大小,而默认池的块大小是由db_block_size参数指定的,这个块大小是最初创建数据库时使用的块大小,也即system和所有temporary表空间的块大小

db block size在建库后并不能修改,但有时候,会把db block  size调大或调小。可以通过db_nk_cache_size实现这些需求。

db_nk_cache_size参数是自oracle9i之后才引入的,增加这些缓存是为了支持数据库中不同的块大小。最多可以有4种非默认的块大小。可以使用如下命令来设置

alter system set db_16k_cache_size=1024M;

意思就是设置块大小为16k,大小为1024M的缓冲区

不同块大小缓存之间是互斥的,无法共享。使用这些非标准块大小可以让默认8k的系统中的数据传输到默认16k的系统中。

 

示例:

Step1 创建一个块大小16k,大小为52M的缓存区

 

SQL>   alter system set db_16k_cache_size=52M;

System altered.

SQL> show parameter cache_size;


NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
client_result_cache_size             big integer 0
db_16k_cache_size                    big integer 52M
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_flash_cache_size                  big integer 0
db_keep_cache_size                   big integer 0
db_recycle_cache_size                big integer 0

 

Setp2 创建表空间使用块大小16k 

 

SQL> create tablespace test_block_16k datafile '+data' size 32M blocksize 16k;

Tablespace created.

select tablespace_name,FILE_NAME,USER_BYTES/USER_BLOCKS/1024 as "per_block_size(K)"
from dba_data_files 
where TABLESPACE_NAME='TEST_BLOCK_16K';

SQL> select tablespace_name,FILE_NAME,USER_BYTES/USER_BLOCKS/1024 as "per_block_size(K)"
  2  from dba_data_files 
  3  where TABLESPACE_NAME='TEST_BLOCK_16K';


TABLESPACE_NAME                FILE_NAME                                          per_block_size(K)
------------------------------ -------------------------------------------------- -----------------
TEST_BLOCK_16K                 +DATA/c1/datafile/test_block_16k.279.825886891                   16

 

Setp3 创建表使用块大小为16k的表空间

 

 

SQL> create table test_16k (id int,name varchar2(32)) tablespace test_block_16k;

Table created.

 

 

SQL> select distinct(segment_name),BYTES/BLOCKS/1024 as "per_block_size(K)"
  2  from dba_extents
  3  where segment_name='TEST_16K';

SEGMENT_NAME                   per_block_size(K)
------------------------------ -----------------
TEST_16K                                      16

 

 

SQL> insert into test_16k values(1,'xyc');

1 row created.

SQL> commit;

Commit complete.

 

Setp4  把db_nk_cache_size设置为0,看是否能在使用这些表空间

 

 

SQL> alter system set db_16k_cache_size=0;

System altered.

 

SQL> insert into test_16k values(2,'xyc');
insert into test_16k values(2,'xyc')

            *
ERROR at line 1:
ORA-00379: no free buffers available in buffer pool DEFAULT for block size 16K

 

--可以看到alter system set db_16k_cache_size=0后表空间无法再使用,alter system set db_16k_cache_size=0实际起了关闭16k区的作用

 

 

 

 

 

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值