Skip to main content

ClickHouse

At a glance
  • Problem solved: produce arbitrary analytical reports in real time directly on billions of raw rows, without pre-aggregating the data in advance.
  • Era: experiment started in 2009 at Yandex, in production in 2012, open source on 15 June 2016, company ClickHouse Inc. founded in September 2021.
  • Created by: Alexey Milovidov and the Yandex.Metrica team (Yandex).
  • Publisher: ClickHouse Inc. (non-Apache project, Apache 2.0 licence).
  • Category: columnar analytical database (OLAP), SQL.

Historical context​

Yandex.Metrica, the Yandex web analytics service launched in 2008, describes itself as the second largest in the world. Its volume grows from 200 million events per day in 2009 to more than 25 billion in 2016. At first, "fixed" reports are pre-aggregated in MySQL (MyISAM): more than 580 billion rows in 2011. Data arrives in time order but is read per website, which means random disk reads. Alexey Milovidov sums it up: a 7,200 RPM disk does 100 to 200 random reads per second, so a 10,000-row report can take more than 10 seconds.

The team then builds two home-made structures. Metrage (since 2010) is an LSM tree that aggregates continuously: 3.37 trillion rows in 2015, but only for a list of reports defined in advance. OLAPServer (prototype written in December 2008, deployed in January 2009) is a small columnar engine on non-aggregated data, limited to integers and reloaded once a day. Milovidov also tests Infobright, InfiniDB, Vertica, MonetDB and LucidDB: none of them can load 100 billion records a day with 500 columns.

Hence the idea behind ClickHouse: combine OLAPServer's columnar storage (aggregation speed) with Metrage's merge tree (real-time updates, data locality), with a real query language and data types. The ClickHouse server appears on 9 March 2012, the same year it goes into production. The MergeTree engine then replaces both prototypes, and ReplicatedMergeTree (through ZooKeeper) opens production to Metrica's customer queries in 2014. By the end of 2014, other Yandex teams (ads, e-commerce, infrastructure) have migrated to it, but the tool is still internal to a single company, with one exception: CERN, which deployed it for the LHCb experiment.

Convinced that other companies are reinventing their own OLAPServer, Milovidov gets his management's approval: the code is published under the Apache 2.0 licence on 15 June 2016. On 20 September 2021, the team leaves Yandex for ClickHouse Inc., co-founded with Aaron Katz (CEO) and Yury Izrailevsky, with nearly $50M in Series A funding (Index Ventures, Benchmark), followed by a $250M Series B in October 2021 at a $2 billion valuation. Until then, ClickHouse was developed at Yandex by a team of 15 engineers.

Key idea​

Pre-aggregate nothing: store every raw event, sorted and compressed column by column, and compute each report at the moment the user asks for it. To make this viable, each query must read as little data as possible (only useful columns, sorted ranges, sparse indexes) and use all available hardware (SIMD, every core, several servers). The accepted trade-off: an engine designed for appending data, not for row-by-row updates.

How it works​

  • MergeTree: the main family of table engines. Each insert creates an immutable part, sorted by the primary key; a background task merges small parts into bigger ones (up to 150 GB by default), on the LSM tree principle but without a hierarchy of levels.
  • Granules and sparse index: the rows of a part are grouped by 8,192 (granules). The primary index keeps only one entry per granule: 1,000 entries are enough for 8.1 million rows, which fits in memory. A filter on the key is resolved by binary search instead of a full scan.
  • Compressed columnar storage: one file per column, LZ4 compression by default, specialised codecs (delta, Gorilla) that can be chained.
  • Smart merges: ReplacingMergeTree keeps the latest version of a row, AggregatingMergeTree aggregates during merges (often behind a materialized view), TTL rules move or delete old data.
  • Vectorized execution: operators process blocks of rows (MonetDB/X100 model), with SIMD instructions chosen at runtime and optional code compilation. A single C++ binary with no dependencies.
  • Distribution: tables split into shards (Distributed engine) and replicated (ReplicatedMergeTree, coordinated by ClickHouse Keeper, written in C++ on Raft, a replacement for ZooKeeper).
CREATE TABLE hits (
EventDate Date,
CounterID UInt32,
UserID UInt64,
URL String
) ENGINE = MergeTree
ORDER BY (CounterID, EventDate);

-- a report computed on the fly over raw data
SELECT EventDate, count() AS page_views
FROM hits
WHERE CounterID = 42 AND EventDate >= '2016-06-01'
GROUP BY EventDate;

The (CounterID, EventDate) ordering applies the Metrica lesson: queries filter by website, so the rows of a given website must sit next to each other on disk.

By the numbers​

FigureContextSource
200 million then over 25 billionEvents received per day by Yandex.Metrica, 2009 then 2016Milovidov, ClickHouse blog
18.3 trillion rowsNon-aggregated Metrica data in ClickHouse, November 2016Milovidov, ClickHouse blog
60 then 426 serversGrowth of Metrica's main cluster over three years (2016 article)Milovidov, ClickHouse blog
2.8 to 3.4 timesAverage speed versus Vertica on web analytics queries, Yandex internal tests (2016)Milovidov, ClickHouse blog
15 engineersSize of the ClickHouse team at Yandex before the company was created (2021)ClickHouse Inc. announcement
2 billion dollarsValuation after the $250M Series B, October 2021"Who we are" page
1,994 contributorsPeople listed in system.contributors, version 24.6 (2024)VLDB 2024 paper

Milestones​

  • December 2008 / January 2009: OLAPServer prototype written then deployed at Yandex.Metrica.
  • 2009: Alexey Milovidov starts the experiment that will become ClickHouse (first commit on 29 May 2009, an optimisation that predates the project).
  • 9 March 2012: the ClickHouse server appears; production use starts the same year.
  • 2014: ReplicatedMergeTree makes it possible to serve Metrica's customer queries; CERN deploys ClickHouse for LHCb.
  • 15 June 2016: open source release under the Apache 2.0 licence.
  • September 2017: Metrica stores 25.1 trillion rows; Cloudflare ingests about 75 billion DNS events per day.
  • 20 September 2021: ClickHouse Inc. is created and the team leaves Yandex.
  • 2022: European offices in Amsterdam and early access programme for the cloud service.
  • 2024: paper "ClickHouse - Lightning Fast Analytics for Everyone" at VLDB.
  • 15 June 2026: ten years of open source, more than 2,000 contributors.

Did you know?​

  • The name: ClickHouse comes from "Clickstream" and "Data wareHouse", hence the mandatory capital H. Andy Pavlo (Carnegie Mellon) gave it, together with Postgres, the award for "best database name of all time".
  • First production use: before MergeTree, ClickHouse first served as a persistent log queue queryable in SQL, according to its creator.
  • Written from scratch: ClickHouse is not derived from any existing database. The first relational operator implemented was LIMIT, and QuickLZ compression was replaced by LZ4 as soon as Milovidov read Yann Collet's blog.
  • Benchmarks embraced: against "DeWitt clauses" that forbid publishing benchmarks, ClickHouse maintains ClickBench (43 queries over 100 million anonymized page hits, more than 45 systems compared in June 2024).

Strengths and limitations​

StrengthsLimitations
Sub-second reports on raw, non-aggregated dataDesigned for appends: updates and deletes go through costly mutations
Sparse indexes and sorting that skip most of the dataNo general ACID transactions: snapshot isolation only
Strong compression, columnar storageJoin optimizer still limited in 2024 (no join reordering, correlated subqueries unsupported in v24.6)
A single C++ binary, from laptop to clusterAsynchronous replication, hence eventual consistency between replicas

Where it fits​

  • Born from the same need as Druid and Pinot: real-time analytics with high ingestion rates. The VLDB paper notes that their segments stay immutable and that they require specialised nodes, whereas ClickHouse merges its parts and fits in a single binary.
  • Alternative to SQL engines on Hadoop: Milovidov considered Impala, Spark SQL or Presto (now Trino) suited to internal analysis but not as the backend of a public web interface.
  • Reads and writes open formats (Parquet) and talks to Kafka or Iceberg through its integration table engines.
  • Embedded cousin: DuckDB, which inspired the chDB in-process mode.

Sources​

To do
  • Date precisely when MergeTree arrived (after March 2012, before 2014: exact date not sourced).
  • The figures from the former "ClickHouse history" page (374 servers, 20.3 trillion rows) are undated: not used in the table.
  • Performance comparisons (Vertica, ClickBench) are published by Yandex then ClickHouse Inc. themselves.
  • Document ClickHouse Cloud (general availability) with a dated source.