Extent有两种分配策略:autoallocate和uniform,在创建表空间时指定,一旦创建不可更改
Uniform默认为1M;
Autoallocate:extent以64K起直至扩展到64M,对应关系如下表
Segment Size Preferred Next Extent Size
============ ==========================
Upto 1m ------------------>64k
Upto 64m ------------------->1m
Upto 1g ------------------->8m
Above 1g ------------------>64m
11202引入隐含参数"_partition_large_extents"(默认为true),所有分区表默认initial extent为8M,另有"_index_partition_large_extents "(默认false)用于索引分区;
过小的extent不但消耗SGA,还会影响全表扫描的性能(见注1)
ASM extent由1个或多个AU组成,ASM使用可变大小的extent用于降低大数据库对SGA的消耗,规则如下:
0-19999区间,extent=AU
20000-39999区间,extent=4*AU
40000+区间,extent=16*AU
注:磁盘组compatible>=11.1
参数
创建表时可指定initial/minextents/next参数,三者与uniform协同工作,关系如下:
当minextents=1时,分配max(initial, uniform);
大于1时,分配max(initial extent, uniform) + (n-1) * size
如果指定了next,size=next,否则size=uniform
测试
create tablespace test
datafile '/u01/app/oracle/oradata/KBCOOK/test01.dbf' size 50m
extent management local uniform. size 1m;
CASE 1
SQL> create table test_tab (col1 varchar2(2)) tablespace test storage(initial 65535 minextents 2);
SQL> select bytes from dba_extents where segment_name = 'TEST_TAB';
BYTES
----------
1048576
1048576
CASE 2
SQL> create table test_tab (col1 varchar2(2)) tablespace test storage(initial 1m minextents 5);
Table created.
SQL> select bytes from dba_extents where segment_name = 'TEST_TAB';
BYTES
----------
1048576
1048576
1048576
1048576
1048576
CASE 3
SQL> create table test_tab (col1 varchar2(2)) tablespace test storage(initial 2m minextents 2);
SQL> select bytes from dba_extents where segment_name = 'TEST_TAB';
BYTES
----------
1048576
1048576
1048576
CASE 4
SQL> create table test_tab (col1 varchar2(2)) tablespace test storage(initial 2m next 3m minextents 3);
Table created.
SQL> select bytes from dba_extents where segment_name = 'TEST_TAB';
BYTES
----------
1048576
1048576
1048576
1048576
1048576
1048576
1048576
1048576
Extent预分配
11g引入extent pre-allocation特性,由SMCO(space management coordinator)负责,其动态spawn子进程Wnnn用于空间分配和回收;
SMCO功能:
1
Extent预分配
数据文件须开启autoextend,SMCO依据历史信息,在表空间里所有尚未达到 maxsize的数据文件间均匀的分配扩展;
2
回收临时段
3
Securefile lob预扩展/回收
如何开启/关闭SMCO
--可动态修改
ALTER SYSTEM SET "_ENABLE_SPACE_PREALLOCATION" = 0;--关闭
ALTER SYSTEM SET "_ENABLE_SPACE_PREALLOCATION" = 3;--激活
此特性有时会产生意料之外的结果,譬如数据文件扩展到maxsize(但实际数据没有这么大)
In 11g, the system tries to keep free extent in the tablespace ahead of time based on allocation projection. In this test case, continuous insert operations caused the tablespace growth rate to be very high, therefore, system "over" extended the tablespace, where the free space cushion is far more than the NEXT value specified by user
AUTOEXTEND Grows To Full Size Without Reason [ID 1459097.1]
Why The Data Files Got Extended Up Over The Weekend [ID 1538442.1]
注1:
db_file_multiblock_read_count决定一次IO最大读取块数,用于全表或快速全索引扫描;
当系统只有非工作量统计信息时,在计算多块读的IO cost公式中充当分母,即值越大oracle越倾向选择全表或快速全索引扫描;
有工作量统计信息时,系统改用MBRC
http://space.itpub.net/15480802/viewspace-739468
并非所有多块读IO一次都读取db_file_multiblock_read_count规定的数量,受如下因素限制:
段头只能单块读;
不能垮越 extent;
如果extent中部分块已经缓存,除非直接读,否则不会重新读取
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/15480802/viewspace-763188/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/15480802/viewspace-763188/