DEV Community

Alex Spinov
Alex Spinov

Posted on

Clickhouse Has a Free Column-Oriented Database That Queries Billions of Rows in Seconds

ClickHouse is a column-oriented OLAP database. It processes analytical queries on billions of rows in real-time — used by Cloudflare, eBay, and Uber.

What You Get for Free

  • Column storage — 10-100x compression
  • Vectorized execution — SIMD optimized
  • SQL — standard SQL with extensions
  • Real-time ingestion — millions of rows/sec
  • Materialized views — pre-aggregated data
  • Distributed — horizontal scaling
  • ClickHouse Cloud — free trial

Quick Start

docker run -p 8123:8123 -p 9000:9000 clickhouse/clickhouse-server
Enter fullscreen mode Exit fullscreen mode

Analytical Queries

CREATE TABLE events (
  timestamp DateTime,
  user_id UInt64,
  event String,
  properties String
) ENGINE = MergeTree()
ORDER BY (timestamp, user_id);

-- Query 1 billion rows in <1 second
SELECT event, count(), uniq(user_id)
FROM events
WHERE timestamp > now() - INTERVAL 7 DAY
GROUP BY event
ORDER BY count() DESC;
Enter fullscreen mode Exit fullscreen mode

ClickHouse vs PostgreSQL

Feature ClickHouse PostgreSQL
Query type OLAP OLTP
1B row query <1 sec Minutes
Storage Columnar Row-based
Compression 10-100x 2-3x

Need analytics DB? Check my work on GitHub or email spinov001@gmail.com for consulting.

Top comments (0)