Overview
ClickHouse is excellent at analytics and weak at transactional workloads. Choosing it for the wrong job is the most expensive mistake. Use this note as a checklist before adopting it.
Core concepts
Good fits:
- Append-mostly event, log, metric and trace data, billions of rows, queried by time and a few dimensions.
- Real-time dashboards and aggregations over wide, denormalised tables.
- High-throughput batch or streaming ingestion with batched inserts (ch-ingestion).
Poor fits:
- OLTP: point reads and writes by key, frequent single-row updates,
SELECT ... FOR UPDATE, multi-statement transactions and strict constraints. Use PostgreSQL, SQL Server or Oracle (transactions-acid). - Frequent updates/deletes of individual rows: each is a mutation, a mask or a patch part (ch-mutations).
- Key-value or document access with sub-millisecond latency: use Redis or a dedicated store.
- Many concurrent small queries (tens of thousands per second): ClickHouse favours fewer, heavier queries.
- Heavy multi-way joins and strict normalised schemas: possible, but the design assumes denormalisation or dictionaries (ch-dictionaries).
- Strong uniqueness guarantees: no primary-key uniqueness; dedupe is eventual (ch-replacing-collapsing-engines).
Typical architecture: an OLTP database or event stream is the source of truth; changes flow through Kafka or CDC into ClickHouse for analytics (ch-columnar-model).
Worked example
Decision sketch for an e-commerce system:
| Need | Choose |
|---|---|
| Orders, inventory, payments (transactions) | PostgreSQL / SQL Server / Oracle |
| Clickstream and page-view events, 5B rows/month | ClickHouse |
| Daily revenue by country dashboard | ClickHouse materialised aggregate (ch-materialized-views) |
| User session cache | Redis |
The same 5-million-row event table that scans in a few milliseconds in ClickHouse (for example SELECT sum(amount) reads 38 MiB in about 7 ms on the test machine) would need partitioning, indexing and tuning to approach that on a row store, while a row-by-row balance update would be far slower in ClickHouse.
Pitfalls and production notes
- Do not let application features depend on read-your-writes behaviour without checking: inserts are visible once flushed, replication is asynchronous by default.
- Plan backups, upgrades and operations; ClickHouse needs real operational care at scale (ch-operations-monitoring).
- Model queries first, then the table and sorting key (ch-sorting-key-sparse-index).
- If you are unsure, benchmark with a copy of production data and your top 20 queries.
Practice questions
- Why is a banking ledger a poor fit for ClickHouse?
- Why does ClickHouse not enforce primary-key uniqueness?
- Describe a pipeline from PostgreSQL to ClickHouse for reporting.
References
- ClickHouse documentation, Use cases and Why is ClickHouse so fast?
Related
ch-columnar-model · ch-mutations · ch-replacing-collapsing-engines · transactions-acid