Index sharding in ClickHouse Cloud: Petabyte-scale data needs petabyte-scale indexing
Index sharding in ClickHouse Cloud splits primary and secondary index analysis across replicas using consistent hashing over data parts. Each replica loads and analyzes only its own slice of the index and returns matching granule ranges for the initiator to merge, so total index memory across the fleet stays at the size of the index instead of growing with replica count. If analysis of a part fails on a remote replica, the initiator falls back to analyzing that part locally. On a 50-billion-row table with 10 replicas, index analysis ran 4.3–7.7× faster (bloom filter, vector and full-text indexes gained the most), with a further 1.4–1.7× gain at 20 replicas.
Related posts
- ClickHouse Release 23.3
ClickHouse mediumAdept
ClickHouse 23.3 LTS adds parallel replicas, which let multiple replicas of the same shard each process distinct data ranges assigned by an initiator node. This allows query speed to scale by adding replicas, especially on shared object storage, without resharding. Dynamic shards via parallel_replicas_custom_key split work with modulo or range predicates, which can skip the final GROUP BY merge. Lightweight deletes are now GA but only remove rows from disk during later merges, so mutations remain the choice for immediate space recovery or compliance. The release also adds MySQL-compatible parseDateTime and Joda-syntax parsing, plus Grafana visualization of query traces from opentelemetry_span_log.
- A Quadrillion Rows across three Clouds: scaling LogHouse
ClickHouse mediumAdept
LogHouse, ClickHouse Cloud's internal logging platform, has grown to 431 PiB uncompressed (27 PiB on disk) and 1.59 quadrillion rows across 36 cells in 33 geoshards on three clouds, ingesting up to 80 GiB/s and 190M rows/s. Writes stay local to each region, with busy regions split into cells keyed by source Kubernetes cluster. Async Inserts cut part creation by 4–24x, and the largest tables moved from monthly to daily partitions once parts hit the max merge size. OTel collectors spill failed batches to S3 so that outages cause delay rather than data loss. On the read side, a three-level Distributed table hierarchy (global, regional, local SharedMergeTree) with region-named shards for pruning gives users one endpoint and sub-second cross-cloud queries.
- How we scaled raw GROUP BY to 100 B+ rows in under a second
ClickHouse mediumAdept
ClickHouse Cloud's parallel replicas feature spreads a single GROUP BY query across every core of every node in a service, with no pre-aggregation or data reshuffling. In the benchmark, 100 billion rows were aggregated in 414 ms at about 1.45 TB/s, compared with 16.6 s on a single 89-core node. The speedup rests on ClickHouse's execution model. Each pipeline stream scans a non-overlapping set of part ranges and builds mergeable partial aggregation states in one of 30+ specialized hash table variants, so any core or node can process any subset of rows and the partial results merge correctly. The post also covers memory behaviour by aggregate function, the reproducible benchmark setup, and how runtime scales vertically (more cores per node) and horizontally (more nodes).
- ClickHouse Release 23.8
ClickHouse mediumAdept
ClickHouse 23.8 makes file reads much faster by using Parquet row-group min/max statistics to skip data, answering count() from file metadata, and pruning files via the _file virtual column without reading them. On a 126GiB PyPI Parquet dataset in GCS, a count dropped from 26.5s to 11.4s, a time-range filter from 84s to 35s, and a 10% filename sample from 4.6s to 0.6s. The release also adds the S3Queue table engine for streaming ingestion from S3. It tracks processed files in ClickHouse Keeper using an unordered mode (with TTL and file-count limits) or an ordered mode keyed on filenames. Direct querying of zip, tar and 7z archives via the file function is also new.
- Super charging your ClickHouse queries
ClickHouse mediumAdept
ClickHouse query speed comes mainly from reading less data: a sparse primary index stores one entry per 8192-row granule and lets binary search skip blocks that can't match the WHERE clause. On the 27.6M-row UK property dataset, re-sorting a copy of the table by (town, price) cuts a full scan to 81.92 thousand rows, and optimize_read_in_order removes the in-memory sort and stops early under LIMIT. Projections do the same job automatically, as hidden tables kept in sync with the main table that can use a different sort order or pre-computed aggregates (backed by AggregatingMergeTree). ClickHouse picks the cheapest projection at query time. Raising query-engine parallelism is the third tuning knob.