April 15, 2011

Low HWM ,High HWM and Direct Path Write

An ASSM segment has two High Water Marks. One is Low High Water Mark, another is High High Water Mark.

Blocks under Low HWM are definitely all formated, other wise if there exist unformatted block exist under Low HWM, then you will get ORA-08103: object no longer exists.
Blocks between Low HWM and High HWM are either can be formatted and unformtted.
Blocks above High HWM are definitely un formatted.

When oracle perform a scan on the segment, it will read blocks one by one from it till the LHWM. Then Oracle will use the bitmap to only read the formatted block between LHWM and HHWM.
And the HHWM is the endline, oracle never read the blocks above HHWM.

When we perform a Direct Path Write, oracle will first sync the LHWM and HHWM (means format all unformated blocks between LHWM and HHWM), then oracle will insert above the LHWM---mean while it is already same with HHWM.


Let's see:
Target table TESTHW Segment header:
-----------------------------------------------------------------
Extent Header:: spare1: 0 spare2: 0 #extents: 18 #blocks: 384
last map 0x00000000 #maps: 0 offset: 2716
Highwater:: 0x0140018c(High HWM) ext#: 17 blk#: 3 ext size: 128
#blocks in seg. hdr's freelists: 0
#blocks below: 259
mapblk 0x00000000 offset: 17
Disk Lock:: Locked by xid: 0x0010.02b.00000009
--------------------------------------------------------
Low HighWater Mark :
Highwater:: 0x0140018c(Low HWM) ext#: 17 blk#: 3 ext size: 128
#blocks in seg. hdr's freelists: 0
#blocks below: 259
mapblk 0x00000000 offset: 17
Level 1 BMB for High HWM block: 0x01400189
Level 1 BMB for Low HWM block: 0x01400189
--------------------------------------------

After truncate the segment:
-----------------------------------------------------------------
Extent Header:: spare1: 0 spare2: 0 #extents: 1 #blocks: 8
last map 0x00000000 #maps: 0 offset: 2716
Highwater:: 0x0140001c ext#: 0 blk#: 3 ext size: 8
#blocks in seg. hdr's freelists: 0
#blocks below: 0
mapblk 0x00000000 offset: 0
Disk Lock:: Locked by xid: 0x000d.028.0000000a
--------------------------------------------------------
Low HighWater Mark :
Highwater:: 0x0140001c ext#: 0 blk#: 3 ext size: 8
#blocks in seg. hdr's freelists: 0
#blocks below: 0
mapblk 0x00000000 offset: 0
Level 1 BMB for High HWM block: 0x01400019
Level 1 BMB for Low HWM block: 0x01400019


Insert some rows, now the LHWM not equal HHWM:
-----------------------------------------------------------------
Extent Header:: spare1: 0 spare2: 0 #extents: 18 #blocks: 384   --segment owns 18 extents
last map 0x00000000 #maps: 0 offset: 2716
Highwater:: 0x01400189 ext#: 16 blk#: 128 ext size: 128     --HHWM on the 17 extent
#blocks in seg. hdr's freelists: 0
#blocks below: 244
mapblk 0x00000000 offset: 16
Unlocked
--------------------------------------------------------
Low HighWater Mark :
Highwater:: 0x01400099 ext#: 15 blk#: 8 ext size: 8       --LHWM on the 17 extent
#blocks in seg. hdr's freelists: 0
#blocks below: 118
mapblk 0x00000000 offset: 15
Level 1 BMB for High HWM block: 0x0140010a
Level 1 BMB for Low HWM block: 0x01400089



Direct Path Load(/*+Append */) one row, pay attention, only one row:
-----------------------------------------------------------------
Extent Header:: spare1: 0 spare2: 0 #extents: 18 #blocks: 384
last map 0x00000000 #maps: 0 offset: 2716
Highwater:: 0x0140018c ext#: 17 blk#: 3 ext size: 128
#blocks in seg. hdr's freelists: 0
#blocks below: 259
mapblk 0x00000000 offset: 17
Disk Lock:: Locked by xid: 0x000d.029.0000000a
--------------------------------------------------------
Low HighWater Mark :
Highwater:: 0x0140018c ext#: 17 blk#: 3 ext size: 128
#blocks in seg. hdr's freelists: 0
#blocks below: 259
mapblk 0x00000000 offset: 17
Level 1 BMB for High HWM block: 0x01400189
Level 1 BMB for Low HWM block: 0x01400189

We can see it just behave as what i describle at the beginning.
But why HHWM move from 0x01400189 to 0x0140018c not to 0x0140018b?
This is because 0x0140018a is metadata block, so the rowdata is insert into the following block 0x0140018b, so the HHWM is 0x0140018c now.
More......