_partition_large_extents和_index_partition_large_extents
alter system set "_partition_large_extents"=false;
alter system set "_index_partition_large_extents"=false;
参考:
http://www.xifenfei.com/2013/08/%E5%88%86%E5%8C%BA%E9%BB%98%E8%AE%A4segment%E5%A4%A7%E5%B0%8F%E5%8F%98%E5%8C%9664k-8m.html
从11.2.0.2开始创建分区表,每个分区默认大小为8M,是由_partition_large_extents参数控制,可以算是11.2.0.2开始的一个新特性,为了减少extent数量,提高分区表性能,而引入的一个参数,默认为true,即分区表的每个extent为8M,这里对于_partition_large_extents为true和false的情况进行了测试。
例1:
数据库参数情况如下:
SQL> select * from v$version;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
PL/SQL Release 11.2.0.4.0 - Production
CORE 11.2.0.4.0 Production
TNS for Linux: Version 11.2.0.4.0 - Production
NLSRTL Version 11.2.0.4.0 - Production
SQL> alter system set "_partition_large_extents"=true;
System altered
SQL> alter system set "_index_partition_large_extents"=true;
System altered
SQL> show parameter _partition_large_extents
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
_index_partition_large_extents string TRUE
_partition_large_extents string TRUE
SQL> show parameter deferred_segment_creation--是否启用延迟段
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
deferred_segment_creation boolean FALSE
1)创建分区表:
CREATE TABLE Table1001
(
idd INT,
iNAME VARCHAR(10),
grade INT
)
PARTITIONBYRANGE(grade)
(
PARTITION part1 VALUESLESSTHAN(10)TABLESPACEtest,
PARTITION part2 VALUESLESSTHAN(MAXVALUE)TABLESPACEtest
);
2)穿件普通表
CREATETABLE table1002
(
idd INT,
iNAME VARCHAR(10),
grade INT
)TABLESPACETEST;
3)创建索引
createindex ind1 on table1001(idd)local tablespacetest;
createindex ind2 on table1002(idd) tablespace test;
createindex ind3 on table1001(iname) tablespace test;
createindex ind4 on table1002(iname) tablespace test;
查询segment视图,确定初始创建表所占空间大小:
select t.segment_name,
t.partition_name,
t.tablespace_name,
t.bytes /1024/1024||'m',
t.blocks,
t.extents
from dba_segments t
where t.tablespace_name ='TEST';
SEGMENT_NAME PARTITION_NAME TABLESPACE_NAME T.BYTES/1024/1024||'M' BLOCKS EXTENTS
-------------------------------------------------------------------------------- -----------------------------
IND1 PART2 TEST 8m 1024 1
IND1 PART1 TEST 8m 1024 1
IND2 TEST 0.0625m 8 1
IND3 TEST 0.0625m 8 1
IND4 TEST 0.0625m 8 1
TABLE1001 PART2 TEST 8m 1024 1
TABLE1001 PART1 TEST 8m 1024 1
TABLE1002 TEST 0.0625m 8 1
结论:从例1可以得出结论,在11.2.0.4版本中,当参数_partition_large_extents等于true时(此时可能不可见),创建分区表默认占用空间大小为每个分区8m,而普通表默认占据空间大小仅0.0625m(64k)。而当_index_partition_large_extents为true时,创建分区索引时,默认分区大小为8m,而创建普通索引默认大小为64k。
例2:
SQL> alter system set "_partition_large_extents"=false;
System altered
SQL> alter system set "_index_partition_large_extents"=false;
System altered
SQL> show parameter _partition_large_extents
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
_index_partition_large_extents string FALSE
_partition_large_extents string FALSE
SQL> show parameter deferred_segment_creation
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
deferred_segment_creation boolean FALSE
创建分区表:
CREATETABLE Table1001
(
idd INT,
iNAME VARCHAR(10),
grade INT
)
PARTITIONBYRANGE(grade)
(
PARTITION part1 VALUESLESSTHAN(10)TABLESPACEtest,
PARTITION part2 VALUESLESSTHAN(MAXVALUE)TABLESPACEtest
);
创建普通表:
CREATETABLE table1002
(
idd INT,
iNAME VARCHAR(10),
grade INT
)TABLESPACETEST;
创建索引:
createindex ind1 on table1001(idd)localtablespacetest;
createindex ind2 on table1002(idd)tablespacetest;
createindex ind3 on table1001(iname)tablespacetest;
createindex ind4 on table1002(iname)tablespacetest;
查询segment视图,确定初始创建表所占空间大小:
select t.segment_name,
t.partition_name,
t.tablespace_name,
t.bytes /1024/1024||'m',
t.blocks,
t.extents
from dba_segments t
where t.tablespace_name ='TEST';
SEGMENT_NAME PARTITION_NAME TABLESPACE_NAME T.BYTES/1024/1024||'M' BLOCKS EXTENTS
-------------------------------------------------------------------------------- -----------------------------
IND1 PART2 TEST 0.0625m 1024 1
IND1 PART1 TEST 0.0625m 1024 1
IND2 TEST 0.0625m 8 1
IND3 TEST 0.0625m 8 1
IND4 TEST 0.0625m 8 1
TABLE1001 PART2 TEST 0.0625m 1024 1
TABLE1001 PART1 TEST 0.0625m 1024 1
TABLE1002 TEST 0.0625m 8 1
结论:通过测试证明,设置_partition_large_extents参数确实是能够控制分区表的extent大小,而且对于分区表,deferred_segment_creation虽然为true,但是在一个分区表中如果有一个子分区插入了记录,那么其他子分区会同时创建segment.对于数据量不多,而且数据大量集中在某几个分区,那强烈建议设置_partition_large_extents为false,节约空间.如果数据量较大,而且数据分布较为均匀,建议设置_partition_large_extents为true.另外对于分区的index也有同样意义的参数为_index_partition_large_extents。
可以看到在11.2.0.2 以后_partition_large_extents参数默认打开(default : TRUE),创建的初始化分区大小为8M。
实际该特性可能在导致以下2个问题:
若配合deferred_segment_creation=false使用则创建具有大量分区的表时,耗时大幅增长
若配合deferred_segment_creation=false使用则建好后空表的所占空间为8M*分区数目,对比关闭该特性的情况会大非常多
转载于:https://www.cnblogs.com/wcwen1990/p/6656545.html