---
title: "ClickHouse and The One Billion Row Challenge"
description: "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."
url: "https://swe.quest/articles/clickhouse-and-the-one-billion-row-challenge-a492ebece6e75794"
canonical: "https://clickhouse.com/blog/clickhouse-one-billion-row-challenge"
source: "ClickHouse"
published: "2024-01-23"
difficulty: "medium"
kind: "How-to"
reading_minutes: 8
tags: ["analytics","sql","performance"]
---

# ClickHouse and The One Billion Row Challenge

A post on [ClickHouse](https://swe.quest/sources/clickhouse.md), published 2024-01-23, 8 min read, How-to. Original: [https://clickhouse.com/blog/clickhouse-one-billion-row-challenge](https://clickhouse.com/blog/clickhouse-one-billion-row-challenge)

## Summary

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. Reading lines with LineAsString and splitting on ';' instead of using the CSV parser cut the time from 27.6s to 19.9s. Loading into a Memory table first, or precomputing aggregates with a Materialized View into an AggregatingMergeTree via a Null engine, makes later queries near-instant but costs 21–26s of load time, so neither beats the single-scan query end to end. ClickHouse SQL using randCanonical and a Box-Muller transform also generates the dataset 6.8x faster than the Java generator.

Written by swe.quest, not by the author.

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

## Topics

- [Analytics & OLAP](https://swe.quest/tags/analytics.md) (Data & databases)
- [SQL](https://swe.quest/tags/sql.md) (Languages)
- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)

## Prerequisites

- SQL GROUP BY aggregation ([easy posts on SQL](https://swe.quest/tags/sql.md?difficulty=easy))
- ClickHouse basics ([easy posts on Analytics & OLAP](https://swe.quest/tags/analytics.md?difficulty=easy))

## Keywords

ClickHouse, ClickHouse Local, One Billion Row Challenge, AggregatingMergeTree, Materialized View, Hetzner

## Related posts

- [ClickHouse and The One Trillion Row Challenge](https://swe.quest/articles/clickhouse-and-the-one-trillion-row-challenge-6f10fe80ade607d9.md): ClickHouse · 2024-03-05 · Medium · 17 min read · Analytics & OLAP, Performance engineering, Cost optimization, Cloud platforms, Query engines
  ClickHouse answers Dask's One Trillion Row Challenge (min/avg/max temperature per station over 2.4TiB of Parquet in S3) in under 3 minutes for $0.56 by querying the data in place with the s3 function on an ephemeral cluster of AWS spot instances provisioned and torn down with Pulumi.
- [ClickHouse Newsletter February 2023: A ‘Sample’ of What’s Happening in the Community](https://swe.quest/articles/clickhouse-newsletter-february-2023-a-sample-of-what-s-happening-in-the-9cf1bfd9f4573dfb.md): ClickHouse · 2023-02-15 · Medium · 9 min read · Analytics & OLAP, SQL, Performance engineering
  ClickHouse's SAMPLE BY clause trades exact answers for speed on very large tables, illustrated with a 425-billion-row Wikistat dataset.
- [Trade secrets: How Coinhall uses ClickHouse to power its blockchain data platform](https://swe.quest/articles/trade-secrets-how-coinhall-uses-clickhouse-to-power-its-blockchain-data-platform-a19f7fb99396fe78.md): ClickHouse · 2024-08-14 · Easy · 5 min read · Analytics & OLAP, Databases, Performance engineering, Cost optimization
  Coinhall, an omnichain trading terminal aggregating swap data from 23 blockchains, moved from BigQuery (about 2-second queries, thousands of dollars per month) to QuestDB and then to self-hosted ClickHouse.
- [Exploring massive, real-world data sets: 100+ Years of Weather Records in ClickHouse](https://swe.quest/articles/exploring-massive-real-world-data-sets-100-years-of-weather-records-in-172f4db963c094b1.md): ClickHouse · 2022-09-07 · Medium · 16 min read · Analytics & OLAP, Data pipelines, SQL, Performance engineering
  A billion-row NOAA GHCN climate dataset (1900–2022) is downloaded, filtered on quality flags and pivoted from one measurement per row to one row per station and day using clickhouse-local, then enriched with station coordinates parsed via the Regexp format.
- [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.

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)
