How ClickHouse Stores Dictionaries in Sharded Hash Tables
The hashed dictionary packs keys compactly, shards the table for parallel loading, and picks its hash table by measured memory footprint.
The hashed dictionary packs keys compactly, shards the table for parallel loading, and picks its hash table by measured memory footprint.
The Native format writes a row count, then for each column its name, type, serialization kind and bulk data — never a row.
ReplacingMergeTree collapses rows by sorting key and version; SELECT FINAL recomputes that collapse at query time.
If your table is sorted by the GROUP BY key, ClickHouse can skip the hash table entirely: it counts each contiguous run of equal keys and emits it.
ClickHouse picks merge candidates with a tiny, explicit cost model: score each contiguous range as sum_size / (count - 1.9), pick the cheapest admissible one, and only ever…