MDC --Multidimensional clustering tables
Databaseadministration >Administrationconcepts >Databaseobjects >Tables>Tablepartitioning and data organization schemes
CURRENTMDC ROLLOUT MODE special register
The CURRENT MDC ROLLOUT MODE special register specifies thebehavior on multidimensional clustering (MDC) tables of DELETEstatements that qualify for rollout processing.
The default value of this register is determined by theDB2_MDC_ROLLOUT registry variable. The value can be changed byinvoking theSET CURRENT MDCROLLOUT MODE statement. When the CURRENT MDC ROLLOUTMODE special register is set to a particular value, the executionbehavior of subsequent DELETE statements that qualify for rollout isimpacted. The DELETE statement does not need to be recompiled for thebehavior to change.
>>-SET--CURRENT--MDC ROLLOUT MODE--+-NONE----------+----------->< +-IMMEDIATE-----+ +-DEFERRED------+ '-host-variable-'
Description
- NONE
- Specifies that MDC rollout optimization during delete operations is not to be used. The DELETE statement is processed in the same way as a DELETE statement that does not qualify for rollout.
- IMMEDIATE
- Specifies that MDC rollout optimization is to be used if the DELETE statement qualifies. If the table has RID indexes, the indexes are updated immediately during delete processing.The delete dblocks are available for reuse after the transaction commits.
- DEFERRED
- Specifies that MDC rollout optimization is to be used if the DELETE statement qualifies. If thetable has RID indexes, index updates are deferred until after the transactions commits.With this option, delete processing is faster and uses less log space, but the deleted blocks are not available for reuse until after the index updates are complete.
- host-variable
- A variable of type VARCHAR. The length of host-var
NOTE: When a block is emptied, it is disassociated from its current logical cell values by removing its BID from the blockindexes.The block can then be reused by another logical cell. This reduces the need to extend the table with new blocks.
实验
TablespaceID = 4
Name = ITS
Type = Database managed space
Contents = All permanent data. Large table space.
State = 0x0000
Detailedexplanation:
Normal
Totalpages = 12800
Useablepages = 12768
Usedpages = 8480
Freepages =4288
…
Extentsize (pages) =32
创建MDC表:
[db2inst1@oc5603811686misc]$ db2 "create table mdctab(c1 int,c2 int) organize by (c1)in its"
Usedpages = 8672
Freepages =4096
使用了192pages,6个extents.
其中包括一个block map对象,占用了两个extents。
[db2inst1@oc5603811686misc]$ db2 "insert into mdctab values(1,1)"
Usedpages = 8704
Freepages =4064
使用了32pages,一个extents.
[db2inst1@oc5603811686misc]$ db2 "insert into mdctab values(2,2)"
Usedpages = 8736
Freepages =4032
[db2inst1@oc5603811686misc]$ db2 "insert into mdctab values(3,3)"
Usedpages = 8768
Freepages =4000
[db2inst1@oc5603811686misc]$ db2 "insert into mdctab values(1,2)"
Usedpages = 8768
Freepages =4000
每多一个不同的c1值,就多了一个block,分配一个extent。
现在开始释放空间实验
[db2inst1@oc5603811686misc]$ db2 "delete from mdctab"
Usedpages = 8768
Freepages = 4000
表空间Freepages依然是4000,也就是说表中的数据全部删除了但是之前已经占用了的扩展数据块没有释放。
手动释放MDC中的空间
现在使用reorg的reclaimextentsonly选项来世放这些扩展数据库。对整个表进行不带选项的reorg也可以释放空闲空间,但必须是脱机执行,而使用reclaimextents only选项则可以联机执行。
[db2inst1@oc5603811686misc]$ db2 reorg table mdctab//V10.1可以联机reorg不带选项。
Usedpages = 8704
Freepages = 4064
释放了两个extents。
[db2inst1@oc5603811686misc]$ db2 reorg table mdctab allow write access
SQL0104N An unexpected token "write" was found following "ALLOW". Expected
tokensmay include: "NO". SQLSTATE=42601
[db2inst1@oc5603811686misc]$ db2 reorg table mdctab reclaim extents allow write access
Usedpages = 8704
Freepages = 4064
跟上面一样,已经释放掉了。我们用了3个extents,释放了3个,另外一个扩展数据块是作为保留块,不会被释放。
OK,如果我们不释放掉这些空间,这些空间会被MDC接下来利用分配,就像我们最上面讲的一样。
[db2inst1@oc5603811686misc]$ db2 "insert into mdctab values(1,1)"
Usedpages = 8736
Freepages = 4032
[db2inst1@oc5603811686misc]$ db2 "insert into mdctab values(2,1)"
Usedpages = 8768
Freepages = 4000
[db2inst1@oc5603811686misc]$ db2 "delete from mdctab"
Usedpages = 8768
Freepages = 4000
[db2inst1@oc5603811686misc]$ db2 reorg table mdctab reclaim extents only allow writeaccess
Usedpages = 8736
Freepages = 4032
我们看,又有一个扩展数据保留了。现在表中是空的,Freepages = 4032,查看表刚刚创建时的状态为4096。
重新reorg,[db2inst1@oc5603811686misc]$ db2 reorg table mdctab
Usedpages = 8704
Freepages = 4064
数据块又收回一个,只会保留一个的。