The high water mark (HWM) is the point in a segment beyond which data blocks are unformatted and have never been used.
HWM对于全表扫描至关重要,HWM以下过多碎片空间会占用更多物理存储,增加物理IO,消耗更多内存缓存(内存读入的块也会有大量碎片)
- MSSM是在freelist中没有free block时,在freelist加入一些HWM以上blocks, 并且在加入时对它们进行格式化。这导致全表扫描其实是扫描HWM以下blocks的
MSSM uses free lists to manage segment space. At table creation, no blocks in the segment are formatted. When a session first inserts rows into the table, the database searches the free list for usable blocks. If the database finds no usable blocks, then it preformats a group of blocks, places them on the free list, and begins inserting data into the blocks.
In MSSM, a full table scan reads all blocks below the HWM.
- ASSM是在bitmap没有free block时,加入HWM以上blocks, 但是是在insert时再对使用的blocks进行format,这导致它有low HWM与HWM两个概念:
Low HWM以下的blocks均为formatted blocks
HWM以下的blocks均为allocated blocks
ASSM uses the bitmap to find free blocks and then formats each block before filling it with data. Every data block in an ASSM segment is in one of the following states:
- Above the HWM:These blocks are unformatted and have never been used.
- Below the HWM:These blocks are in one of the following states:
Allocated, but currently unformatted and unused
Formatted and contain data
Formatted and empty because the data was deleted
Figure 12-24 depicts an ASSM segment as a horizontal series of blocks.
At table creation, the HWM is at the beginning of the segment on the left.
Suppose that a transaction inserts rows into the segment. The database must allocate a group of blocks to hold the rows. The allocated blocks fall below the HWM. The database formats a bitmap block in this group to hold the metadata, but does not preformat the remaining blocks in the group.
In Figure 12-25, As inserts occur, the database can write to any block with available space. The low high water mark (low HWM) marks the point below which all blocks are known to be formatted because they either contain data or formerly contained data.
In Figure 12-26, the database chooses a block between the HWM and low HWM and writes to it. The database could have just as easily chosen any other block between the HWM and low HWM, or any block below the low HWM that had available space.
下面newly filled blocks两边的blocks均为unformatted
In Figure 12-26, the blocks to either side of the newly filled block are unformatted.
全表扫描会使用扫描全部low HWM以下blocks,low HWM到HWM之间的blocks选择性读
The low HWM is important in a full table scan. Because blocks below the HWM are formatted only when used, some blocks could be unformatted, as in Figure 12-26. For this reason, the database reads the bitmap block to obtain the location of the low HWM. The database reads all blocks up to the low HWM because they are known to be formatted, and then carefully reads only the formatted blocks between the low HWM and the HWM.
Low HWM永远保持在HWM相同或以下水位线
When the blocks between the HWM and low HWM are full, the HWM advances to the right and the low HWM advances to the location of the old HWM. As the database inserts data over time, the HWM continues to advance to the right, with the low HWM always trailing behind it. Unless you manually rebuild, truncate, or shrink the object, the HWM never retreats.