---
title: "ClickHouse and The One Trillion Row Challenge"
description: "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."
url: "https://swe.quest/articles/clickhouse-and-the-one-trillion-row-challenge-6f10fe80ade607d9"
canonical: "https://clickhouse.com/blog/clickhouse-1-trillion-row-challenge"
source: "ClickHouse"
published: "2024-03-05"
difficulty: "medium"
kind: "Case study"
reading_minutes: 17
tags: ["analytics","performance","cost-optimization","cloud","query-engines"]
---

# ClickHouse and The One Trillion Row Challenge

A post on [ClickHouse](https://swe.quest/sources/clickhouse.md), published 2024-03-05, 17 min read, Case study. Original: [https://clickhouse.com/blog/clickhouse-1-trillion-row-challenge](https://clickhouse.com/blog/clickhouse-1-trillion-row-challenge)

## Summary

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. ARM c7g.12xlarge instances were chosen on spot price per vCPU and availability, since the workload was CPU-bound rather than network-bound. Raising max\_download\_buffer\_size to 50MB so each ~25MB file is fetched by a single thread cut S3 read wait, increased throughput to ~920MB/s and dropped a 111-billion-row test from 454s to 303s, with further thread tuning following. Loading the data into a MergeTree first would answer the query in 16 seconds, at the cost of load time.

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)
- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)
- [Cost optimization](https://swe.quest/tags/cost-optimization.md) (Reliability & operations)
- [Cloud platforms](https://swe.quest/tags/cloud.md) (Infrastructure)
- [Query engines](https://swe.quest/tags/query-engines.md) (Data & databases)

## Prerequisites

- SQL aggregation ([easy posts on SQL](https://swe.quest/tags/sql.md?difficulty=easy))
- AWS EC2 and S3 ([easy posts on Cloud platforms](https://swe.quest/tags/cloud.md?difficulty=easy))
- Parquet format

## Keywords

ClickHouse, One Trillion Row Challenge, Parquet, Amazon S3, AWS spot instances, Pulumi, c7g, Dask

## Related posts

- [Getting Data Into ClickHouse - Part 3 - Using S3](https://swe.quest/articles/getting-data-into-clickhouse-part-3-using-s3-3c57bebcb705e26d.md): ClickHouse · 2022-09-16 · Medium · 21 min read · Analytics & OLAP, SQL, Cloud platforms, Performance engineering, Data pipelines
  ClickHouse can both query data in place on Amazon S3 and ingest it, shown here on an 11.5-billion-row, ~600GB forex tick dataset stored as zstd CSV and Parquet.
- [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.
- [A Deep Dive into Apache Parquet with ClickHouse - Part 1](https://swe.quest/articles/a-deep-dive-into-apache-parquet-with-clickhouse-part-1-cafa50694ad68bf6.md): ClickHouse · 2023-04-18 · Medium · 11 min read · Analytics & OLAP, Data pipelines, SQL
  ClickHouse can read and write Apache Parquet through its file and s3 table functions, using the same Parquet code in ClickHouse Local and ClickHouse Server.
- [Join me if you can: ClickHouse vs. Databricks vs. Snowflake - Part 1](https://swe.quest/articles/join-me-if-you-can-clickhouse-vs-databricks-vs-snowflake-part-1-abef280c3cc66c97.md): ClickHouse · 2025-06-24 · Easy · 7 min read · Analytics & OLAP, Performance engineering, Query engines, Cost optimization
  ClickHouse Cloud ran a third-party, join-heavy coffee-shop star-schema benchmark (17 queries, originally built to compare Databricks and Snowflake) with no query rewrites or tuning, and came out faster and cheaper at every scale from 721 million to 7.2 billion rows.
- [ClickHouse Release 23.8](https://swe.quest/articles/clickhouse-release-23-8-8db1ebb65d969c75.md): ClickHouse · 2023-09-15 · Medium · 10 min read · Analytics & OLAP, Query engines, Data pipelines, Performance engineering
  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.

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)
