Oracle Database - High Water Mark (HWM) - boundary between used and unused space


The High water mark is the boundary between used and unused space:

You can think at the high-water mark (HWM) as the rightmost block that ever contained data in a (data file|segment)


<MATH> \begin{array}{rrl} \text{High Water Mark} & = & \text{TOTAL BLOCKS} - \text{UNUSED BLOCKS} - 1 \\ & = & \text{USER_SEGMENTS.BLOCKS} - \text{USER_TABLES.EMPTY_BLOCKS} - 1 \end{array} </MATH>

select file_id, max(block_id+blocks-1) hwm
from dba_extents
group by file_id

The DBMS_SPACE.UNUSED_SPACE returns values for USED BLOCKS and TOTAL BLOCK for a segment. Calculate the HWM as (TOTAL_BLOCKS – USED BLOCKS).



  • rebuilt,
  • truncated, (TRUNCATE will reset the HWM of a table back to 'zero')
  • or shrunk (shrinking of a segment is a new Oracle 10g feature that is supported only if the segment is in an ASSM tablespace).


DBMS_SPACE.SPACE_USAGE procedure shows the space usage of data blocks under the segment High Water Mark.



You have to understand Oracle storage.

Each table is made up of logisch segment that are made of physique extents and each extent is made up of oracle blocks - a common block size is 8k. So you have a table with 10 extents (80K).

You populate your table with 2 million rows of data and you will have many hundreds of extents. Now lets assume that you delete over half of the records in the table. Oracle still has the same number of extents but many of the blocks are empty. When you run a query against the table Oracle will scan through all the blocks including empty ones looking for data.

So you can think of the total number of extents / blocks used as the high water mark.


The high water mark divide a segment into used blocks free blocks

Blocks below the high water mark (used blocks) have at least once contained data. This data might have been deleted. Since Oracle knows that blocks beyond the high water mark don't have data, it only reads blocks up to the high water mark in a full table scan. Oracle keeps track of the high water mark for a segment in the segment header. Moving the high water mark In normal DB operations, the high water mark only moves upwards, not downwards. The exceptions being the truncate. If there is a lot of free space below the high water mark, one might consider to use alter table move statements. See On shrinking table sizes.


Documentation / Reference

Powered by ComboStrap