使用 Shrink Table 改变 HWM 高水位线

本文介绍了如何通过Shrink Table操作来解决数据库中HWM(高水位线)问题,从而提高查询效率。在删除大量数据后,表的HWM不会自动下降,导致查询时产生不必要的物理读。通过Shrink Table,可以有效地释放碎片空间,降低HWM,减少物理读,提升查询性能。
摘要由CSDN通过智能技术生成

当对表做delete操作的时候, 数据块是不会被释放的。 如果遇到查询效率很慢,排除索引和执行计划的因素外, 发现有大量物理读,但是返回记录行却很少。 这种情况就要考虑 有HWM问题。 需要考虑重建表或者使用SHRINK,MOVE 去降低 HWM。

Shrink table 测试

1. 创建含有数据的测试表

2. 查看表的段块使用情况---参考 show_space procedure 

 

Total Blocks............................256
Total Bytes.............................2097152
Unused Blocks...........................0
Unused Bytes............................0
Last Used Ext FileId....................44
Last Used Ext BlockId...................696704
Last Used Block.........................128
HWM AT BlockID..........................171
HWM AT BlockS...........................256


Thesegment is analyzed
0% -- 25% free spaceblocks..............0
0% -- 25% free spacebytes...............0
25% -- 50% free spaceblocks.............0
25% -- 50% free spacebytes..............0
50% -- 75% free spaceblocks.............0
50% -- 75% free spacebytes..............0
75% -- 100% free spaceblocks............0
75% -- 100% free spacebytes.............0
Unused Blocks...........................0
Unused Bytes............................0
Total Blocks............................256
Total bytes.............................2097152

3. 删除表中的一些数据

4. 分析表

5.查看表的段块使用情况


Total Blocks............................256
Total Bytes.............................2097152
Unused Blocks...........................0
Unused Bytes............................0
Last Used Ext FileId....................44
Last Used Ext BlockId...................696704
Last Used Block.........................128
HWM AT BlockID..........................171
HWM AT BlockS...........................256

Thesegment is analyzed
0% -- 25% free spaceblocks..............1
0% -- 25% free spacebytes...............8192
25% -- 50% free spaceblocks.............1
25% -- 50% free spacebytes..............8192
50% -- 75% free spaceblocks.............0
50% -- 75% free spacebytes..............0
75% -- 100% free spaceblocks............23
75% -- 100% free spacebytes.............188416
Unused Blocks...........................46
Unused Bytes............................376832
Total Blocks............................

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值