HOBT: The Hierarchy of Data Organization
Data in SQL Server does not lie around randomly. It forms structures whose branches lead to data pages. HOBT (Heap Or B-Tree) is the storage structure behind each B-tree index and heap table. It is the skeleton of data organization and addressing — from the root, through intermediate levels, down to the leaf pages of a B-tree.
“Structure is the form in which order exists.” — SQLManiak
🧩 What is a HOBT in practice?
Each partition of an index or heap has one HOBT (a table with one partition and three indexes has four HOBTs; a table with four partitions and two indexes has eight).
HOBT is not the same as an index object: it describes the physical structure for a particular index or heap partition.
🆔 HOBT identifier: hobt_id — associated with the structure during its lifetime, but it can change after certain rebuild operations.
📦 HOBTs and allocation units
A HOBT-related partition may use up to three allocation-unit types:
- IN_ROW_DATA — rows stored in regular 8 KB data pages.
- ROW_OVERFLOW_DATA — variable-length data moved off-row when the row exceeds the in-row limit.
- LOB_DATA — large objects such as XML and
VARBINARY(MAX).
📎 Relationship:
sys.allocation_units.container_id = sys.partitions.hobt_id for IN_ROW_DATA and ROW_OVERFLOW_DATA; LOB_DATA uses the partition identifier instead.
🌲 Heaps versus B-trees
Heap:
- no clustered index key,
- data pages are not logically ordered by a clustered key,
- updates that enlarge rows can create forwarded records.
B-tree index:
- ordered index structure,
- clustered index leaf level contains the table’s data rows,
- nonclustered index leaf level contains keys and row locators (
RIDor clustered key).
🗺️ Page maps and metadata
Metadata and allocation maps: PFS (Page Free Space), GAM/SGAM (extent allocation), and IAM (Index Allocation Map) connect storage structures to allocated pages.
Tree diagnostics:
sys.dm_db_index_physical_stats— levels, fragmentation, forwarded records,sys.dm_db_database_page_allocations— allocation details (undocumented),DBCC PAGE/IND— deeper inspection (undocumented).
🔍 Quick DMVs: HOBTs in your database
📘 HOBT overview
| |
📊 Tree levels and physical statistics
| |
🔦 Which heaps have forwarded rows?
| |
🧪 Lab: See HOBTs in action (copy and paste)
| |
🔎 After converting a heap into a clustered index, page layout and identifiers such as
hobt_idmay change. That is expected.
🧭 Physical row location (RID / clustered key)
| |
If you want to go deeper (in a lab, use caution in production):
| |
🚨 Common warning signs and remedies
1️⃣ Heap with forwarded records
- Symptom:
forwarded_record_count > 0. - Impact: additional page hops and I/O.
- Remedy: rebuild the heap with
ALTER TABLE ... REBUILD, or consider an appropriate clustered key.
2️⃣ An overly deep tree
- Symptom: high
index_leveland largepage_count. - Impact: more intermediate page reads.
- Remedy: review the key design, fill factor, partitioning, and compression.
3️⃣ Excessive ROW_OVERFLOW / LOB data
- Symptom: large
ROW_OVERFLOW_DATAorLOB_DATAallocations. - Impact: additional reads.
- Remedy: review column design, separate rarely accessed attributes, and consider compression.
🧰 DBA checklist (HOBT-aware)
- Inventory HOBTs with
sys.partitionsandsys.allocation_units. - Review tree levels and fragmentation with
sys.dm_db_index_physical_stats. - Identify heaps with forwarded records.
- Measure allocation units (
IN_ROW_DATA,ROW_OVERFLOW_DATA,LOB_DATA). - Plan appropriate
REBUILDorREORGANIZEoperations. - Monitor
page_count, forwarded records, and page density in Grafana.
🧩 Example view: dbo.vHobtHealth
| |
🧭 Summary
HOBT is where logical index organization meets the physics of pages. By understanding hobt_id and related allocation units, you can:
- understand where rows are stored,
- diagnose forwarded records, tree depth, and fragmentation,
- design clustered keys and partitions more deliberately.
🔧 TL;DR: Tools
| Goal | DMV / function |
|---|---|
| Map pages | sys.partitions.hobt_id ⇄ sys.allocation_units.container_id (for IN_ROW_DATA / ROW_OVERFLOW_DATA) |
| Physical statistics | sys.dm_db_index_physical_stats |
| Page allocations | sys.dm_db_database_page_allocations |
| Row location | %%physloc%%, fn_PhysLocFormatter |
| Page diagnostics (lab) | DBCC IND, DBCC PAGE |