Index Size Calculator

Estimate B-tree index size from row count, key width, and pointer size. Plan database index storage for any RDBMS engine.

bytes
bytes
MB
bytes
Single Index Size
1.05 GB
Raw 858.3 MB + 217.5 MB overhead (25%)
Total Index Storage
3.15 GB
3 index(es) × 1.05 GB
Tree Depth
4 levels
137,363 leaf pages, 364 entries/page
Internal Nodes
3.0 MB
378 pages of non-leaf data
Index-to-Data Ratio
33.8%
3.15 GB indexes / 9.31 GB data
Entry Size
18 bytes
Key 12B + Pointer 6B

Index vs Data Size

Data 75%
Indexes 25%

Fill Factor Impact

Fill FactorPer IndexTotal (3 indexes)vs Current
1%1.20 GB3.60 GB+459.8 MB
1%1.05 GB3.15 GB← current
1%956.6 MB2.80 GB-357.6 MB
1%861.3 MB2.52 GB-643.7 MB

Index Count Scaling

IndexesTotal SizeIndex:Data RatioVisual
11.05 GB0%
22.10 GB0%
33.15 GB0%
Column Size Reference for Index Keys
Column TypeBytesCommon Index Use
INT4PK, FK references
BIGINT8PK (large tables), snowflake IDs
UUID16PK (distributed systems)
TIMESTAMP8Range queries, time-series
DATE4Partition keys, reporting
VARCHAR(50) avg 2020Lookup fields, slugs
VARCHAR(255) avg 4040Email, names
BOOLEAN1Partial index filter
INET / CIDR16IP range lookups
INT + TIMESTAMP12Composite FK + time range
Planning notes, formulas, and examples

About the Index Size Calculator

Database indexes dramatically improve query performance, but they come at a storage cost. Every B-tree index stores a sorted copy of the indexed columns plus internal pointers that link tree nodes together. As tables grow to millions or billions of rows, index sizes can rival or exceed the base table size—especially when multiple indexes exist on the same table.

This calculator estimates the on-disk size of a B-tree index using the fundamental formula: rows × (key width + pointer size) × overhead factor. The overhead factor accounts for B-tree node fill rates (typically 67–90%), internal node storage, page headers, and alignment padding. By understanding index size before you create one, you can make informed decisions about which indexes to add, which to drop, and how much storage to provision.

Whether you're sizing a new index on a multi-billion-row analytics table or auditing existing indexes for a capacity review, this calculator gives you a fast, reliable estimate.

When This Page Helps

Creating an oversized index can exhaust disk space and slow write operations. Not creating a needed index degrades query performance. This calculator helps you find the right balance by estimating index storage before deployment, so you can plan capacity and prioritize which indexes provide the best performance-per-byte tradeoff.

How to Use the Inputs

  1. Enter the total number of rows in the table.
  2. Enter the key width in bytes (sum of all indexed column widths).
  3. Enter the pointer size in bytes (typically 6–8 for most databases).
  4. Adjust the overhead factor to account for fill rate and internal nodes.
  5. Optionally enter the number of indexes to estimate total index storage.
  6. Review the estimated index size per index and total.
Formula used
index_size = rows × (key_bytes + pointer_bytes) × overhead_factor; total_index_storage = index_size × number_of_indexes

Example Calculation

Result: 1.26 GB per index; 3.77 GB total

50 million rows × (12 + 6) bytes = 900 MB raw. With a 1.5× overhead factor (accounting for ~67% fill rate and internal nodes), each index is approximately 1,350 MB (1.26 GB). Three such indexes total 3.77 GB of index storage.

Tips & Best Practices

  • B-tree fill factor is typically 70–90%; use an overhead factor of 1.1–1.5 to compensate.
  • Composite indexes store all indexed columns—sum their byte widths for the key size.
  • PostgreSQL B-tree pages are 8 KB with ~24 bytes of header per page; factor this into overhead.
  • Covering indexes (INCLUDE columns) add non-key column widths to the leaf node size.
  • Partial indexes on filtered subsets can dramatically reduce index size.
  • Monitor actual index size with pg_relation_size() or sys.dm_db_index_physical_stats.
  • Drop unused indexes—they consume storage and slow inserts, updates, and deletes.

Understanding B-tree Index Structure

A B-tree index is a balanced tree with leaf nodes containing the indexed key values and pointers back to heap rows. Internal nodes contain separator keys and child page pointers. The depth of the tree is typically 3—4 levels for tables up to billions of rows, keeping lookups fast.

Fill Factor and Fragmentation

When an index page fills up, it splits into two half-full pages. Over time, random inserts cause fragmentation that bloats index size beyond the theoretical minimum. Periodic REINDEX or ALTER INDEX REBUILD operations reclaim this wasted space. Set FILLFACTOR below 100 for write-heavy workloads to leave room for future inserts.

Practical Index Sizing Tips

For initial capacity planning, estimate each index at 1.3–1.5× the raw key+pointer size. After the database is running, validate with actual statistics. Consider dropping low-selectivity indexes on columns with few distinct values—they consume space without improving query plans.

Sources & Methodology

Last updated:

Frequently Asked Questions

  • B-tree nodes are not 100% full. The default fill factor is typically 70–90%, meaning 10–30% of each page is empty. Internal (non-leaf) nodes add further overhead. An overhead factor of 1.2–1.5 accounts for these inefficiencies.