B-tree Index Size and Levels
Compare storage size and levels in a simplified B-tree page structure
This simplified model uses uniform key and pointer widths. It does not equal the index file size of a real database.
Results
—byte
—levels
- Equivalent in MiB
- —MiB
- Total page count
- —pages
- Leaf page count
- —pages
- Internal page count
- —pages
- Entries per leaf page
- —entries
- Maximum internal page fanout
- —child pages
Results update automatically when the required values are entered.
Method, applicability and sources
Calculation method
Leaf entry capacity = floor(floor(page capacity×fill factor÷100)÷(key width+pointer width)). Leaf page count = max(1,ceil(row count÷entry capacity)). Maximum internal fanout = floor((page capacity+key width)÷(key width+pointer width)). Repeat upper-level page count = ceil(lower-level page count÷maximum fanout) until only 1 page remains. Capacity = total page count across all levels×page capacity.
Worked example (hypothetical values)
For 1,000 rows, a key width of 16 bytes, pointer width of 8 bytes, page capacity of 4,096 bytes, and fill factor of 75%, each leaf page holds 128 entries. There are 8 leaf pages and 1 internal page, giving 9 pages, 36,864 bytes, and 2 levels in total.
Applicability and limitations
A static, uniform-width B-tree/B+tree estimate with one key and row pointer per row. Excludes database-specific page headers, row identifiers, alignment, high keys, metapages, MVCC, replication, duplicate-key compression, and splits or fragmentation during updates. Distinguish this estimate from measured PostgreSQL index size or prediction of actual tree height.
Method and sources
Method: generic-btree-page-estimate-v1(2026-11-13). Data recorded: 2026-11-13.