Tools · Indexing

Sparse index calculator

A MergeTree primary index keeps one mark per granule, not one entry per row. Enter your table's shape to see how many marks that is and roughly how much memory the index needs.

Key size: sum of the ORDER BY columns' fixed sizes — e.g. UInt32 + DateTime = 8 bytes. Each part rounds its last granule up, so more parts means a few more marks.

Granules / marks—
Primary index in memory—
Same data, one entry per row—
Rows per mark—

How it's computed

Marks ≈ rows ÷ index_granularity, plus up to one extra per part for the partial last granule. Index memory ≈ marks × key bytes. The dense figure is what a one-entry-per-row index over the same key would need, for comparison.

This is an estimate. Adaptive granularity (index_granularity_bytes) can make granules smaller than index_granularity rows when rows are wide, and variable-length key columns such as String vary per row. For the real number, ask the server:

SELECT table,
       sum(marks) AS marks,
       formatReadableSize(sum(primary_key_bytes_in_memory)) AS pk_in_memory
FROM system.parts
WHERE active AND database = currentDatabase()
GROUP BY table
ORDER BY sum(primary_key_bytes_in_memory) DESC;