---
title: "How we scaled raw GROUP BY to 100 B+ rows in under a second"
description: "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."
url: "https://swe.quest/articles/how-we-scaled-raw-group-by-to-100-b-rows-in-under-a-second-c36aee54a6541514"
canonical: "https://clickhouse.com/blog/clickhouse-parallel-replicas"
source: "ClickHouse"
published: "2025-09-29"
difficulty: "medium"
kind: "Deep dive"
reading_minutes: 23
tags: ["query-engines","analytics","performance","distributed-databases","scalability"]
---

# How we scaled raw GROUP BY to 100 B+ rows in under a second

A post on [ClickHouse](https://swe.quest/sources/clickhouse.md), published 2025-09-29, 23 min read, Deep dive. Original: [https://clickhouse.com/blog/clickhouse-parallel-replicas](https://clickhouse.com/blog/clickhouse-parallel-replicas)

## Summary

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).

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Query engines](https://swe.quest/tags/query-engines.md) (Data & databases)
- [Analytics & OLAP](https://swe.quest/tags/analytics.md) (Data & databases)
- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)
- [Distributed databases](https://swe.quest/tags/distributed-databases.md) (Data & databases)
- [Scaling](https://swe.quest/tags/scalability.md) (Distributed systems)

## Prerequisites

- SQL GROUP BY and aggregates ([easy posts on SQL](https://swe.quest/tags/sql.md?difficulty=easy))
- hash tables
- columnar storage basics

## Keywords

ClickHouse, ClickHouse Cloud, parallel replicas, GROUP BY, hash aggregation, SIMD

## Related posts

- [Introducing multi-stage distributed query execution in ClickHouse Cloud](https://swe.quest/articles/introducing-multi-stage-distributed-query-execution-in-clickhouse-cloud-49bf049f23a569d6.md): ClickHouse · 2026-05-27 · Hard · 14 min read · Query engines, Distributed databases, Analytics & OLAP, Performance engineering
  ClickHouse Cloud adds multi-stage distributed query execution, splitting a query plan into stages connected by exchange operators (Gather, Shuffle, Broadcast, Scatter) so intermediate data can be repartitioned between nodes mid-query.
- [ClickHouse and The One Billion Row Challenge](https://swe.quest/articles/clickhouse-and-the-one-billion-row-challenge-a492ebece6e75794.md): ClickHouse · 2024-01-23 · Medium · 8 min read · Analytics & OLAP, SQL, Performance engineering
  ClickHouse Local solves the One Billion Row Challenge (min/mean/max temperature per station from a 13GB text file) in about 20 seconds on an 8-core Hetzner VM, versus nearly 3 minutes for the Java baseline.
- [Why ClickHouse Cloud wins at real-time analytics](https://swe.quest/articles/why-clickhouse-cloud-wins-at-real-time-analytics-ff3bf2806ccb7be7.md): ClickHouse · 2026-10-28 · Medium · 21 min read · Analytics & OLAP, Storage engines, Query engines, Performance engineering, Cost optimization
  In the CostBench streaming benchmark (113.2 billion stock quotes ingested at about 1M rows/s while queries ran), ClickHouse Cloud scored 412× to 1,996× better end-to-end performance per dollar than Snowflake, Databricks, BigQuery and Redshift Serverless.
- [Join me if you can: ClickHouse vs. Databricks vs. Snowflake - Part 2](https://swe.quest/articles/join-me-if-you-can-clickhouse-vs-databricks-vs-snowflake-part-2-66aede87450dc5eb.md): ClickHouse · 2025-06-25 · Medium · 8 min read · Analytics & OLAP, Performance engineering, Query engines, SQL
  Replacing fact-to-dimension joins with in-memory dictionaries in ClickHouse Cloud sped up a 17-query join benchmark over 1.4 billion rows by 1.9–3.5× in total runtime, up to 6.6× on individual queries, and cut cost by up to 60%.
- [Parallelizing ClickHouse aggregation merge for fixed hash map](https://swe.quest/articles/parallelizing-clickhouse-aggregation-merge-for-fixed-hash-map-9fc83cd0ed214dc7.md): ClickHouse · 2025-12-16 · Hard · 6 min read · Query engines, Performance engineering, Concurrency, Memory management, C & C++
  ClickHouse 25.11 parallelizes the merge phase for GROUP BY on 8- and 16-bit keys, which use an array-backed FixedHashMap.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
