Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

ClickHouse 28 min read Research mediumAdept

ClickHouse vs. Elasticsearch: The Billion-Row Matchup

On a single 32-core c6a.8xlarge node loaded with 1, 10 and 100 billion PyPI download rows, ClickHouse beats Elasticsearch on count(*) GROUP BY aggregations (Elasticsearch terms aggregations). ClickHouse needs 12–19x less storage and delivers at least 5x lower query latency, so roughly 4x cheaper hardware matches Elasticsearch's latency. Its materialized views are also cheaper in storage and compute than Elasticsearch transforms for continuous summarization. The setup details cover ILM rollover, index sorting by cardinality, LZ4 vs DEFLATE/ZSTD codecs, _source tradeoffs and shard parallelism, and note that Elasticsearch could not ingest the 100B-row dataset.

Related posts

  • ClickHouse vs. Elasticsearch: The Mechanics of Count Aggregations

    ClickHouse mediumAdept

    ClickHouse runs count(*) GROUP BY aggregations in parallel at three levels: SIMD within column values, multiple cores over arbitrary data ranges, and multiple nodes over shards. Partial aggregation states let the results be merged exactly. Elasticsearch's terms aggregation instead uses one thread per shard and merges shard-local top-n results. That approach gives approximate counts across shards unless shard_size is raised, always requires a size limit, and is capped by max_buckets. For continuous summarization, ClickHouse's -State/-Merge combinators with AggregatingMergeTree and materialized views aggregate incrementally during background merges. Elasticsearch transforms must keep raw data and re-aggregate whole buckets on every checkpoint, so they are not real-time.

  • Do you still need Elasticsearch for log analytics? ClickHouse says no.

    ClickHouse mediumAdept

    ClickHouse's redesigned inverted-index full-text search feeds matches directly into its vectorized analytical engine, and on a reproducible OpenTelemetry log benchmark at 1B, 10B and 50B rows it ran a nine-query search-plus-aggregation suite 2-6x faster than Elasticsearch, with a much smaller storage footprint. Both systems ran single-node on identical m6i.8xlarge instances with matching sort orders, result caches disabled, and cold and hot runs measured separately. Elasticsearch was tested with Query DSL, which was faster than ES|QL. The storage gap comes from ClickHouse's per-column general-purpose compression and from Elasticsearch's need to keep _source and stored fields. Ingesting 50B rows took under 4 hours in ClickHouse versus about 5 days in a tuned Elasticsearch setup.

  • How Rokt Achieved Real-time Reporting with ClickHouse

    ClickHouse easyNovice

    Rokt replaced an Elasticsearch-backed reporting layer with ClickHouse. Elasticsearch lacked flexible group-by and filtering, had no S3 loading or joins, required JSON queries, and forced full re-ingestion whenever a label changed. After ruling out Pinot, Druid, Snowflake, StarRocks and Citus, the team benchmarked ClickHouse against Redshift: ClickHouse was about 3x cheaper, handled up to 200 queries per second with a maximum query time of six seconds, and stored 500 GB of gzipped Parquet in roughly the same space, about one sixth of the Elasticsearch footprint. The current self-managed setup runs ClickHouse in an autoscaling group with ZooKeeper behind network load balancers, and Rokt plans to move to ClickHouse Cloud to offload replication, sharding and backups.

  • Contentsquare Migration from Elasticsearch to ClickHouse

    ClickHouse mediumAdept

    Contentsquare replaced 14 Elasticsearch clusters with ClickHouse over a phased migration. They first built a new product on ClickHouse, then shadowed production queries endpoint by endpoint to compare results, then moved customers one at a time over six months with zero regressions. The result was 11x lower infrastructure cost, 10x better p99 latency, and longer query windows and retention. Key design pieces were a Kafka-fed ingestion service (clickin) that writes shard-aligned data in ClickHouse native format via clickhouse-local, and an AST-based query optimizer that propagates partition/sort-key conditions and distributed_group_by_no_merge, merges subqueries, and gave a 10x speedup on the slowest 5% of queries.

  • Didi Migrates from Elasticsearch to ClickHouse for a new Generation Log Storage System

    ClickHouse mediumAdept

    Didi replaced Elasticsearch with ClickHouse for petabyte-per-day log and trace storage, cutting machine cost by 30% and speeding up queries about 4x on a 400+ node single-replica deployment peaking at 40 GB/s writes and ~200 QPS. A single Flink write pipeline feeds a Log cluster, and materialized views populate a physically isolated Trace cluster plus AggregatingMergeTree trace index tables, with cold data tiered to HDFS. Schema design rounds log time to the hour as the leading sort key, partitions by day, and moves unfiltered fields into Map columns to limit small files. Operational fixes covered per-table write-node allocation for low-traffic tables, Flink-side throttling, a native TCP Flink connector, and HDFS tiering changes that cut restart time from 1 hour to 1 minute.

The quest for software engineering knowledge.

Look:
Layout: