MDC 设置CURRENTMDC ROLLOUT MODE
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
数据块又收回一个,只会保留一个的。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 零经验选手,Compose 一天开发一款小游戏!
· 因为Apifox不支持离线,我果断选择了Apipost!
· 通过 API 将Deepseek响应流式内容输出到前端