Monday morning: someone asks why revenue on the dashboard doesn't match the finance sheet, and the query behind it has been running since you got in. The answer is that the two databases do different jobs. Keep Postgres for the app and its updates. Use ClickHouse for reports over a large history. Keep Postgres as your application's transactional system of record and add ClickHouse for analytics, replicating committed changes to ClickHouse with CDC [1]ClickHouse describes itself as a real-time analytics database management system [5].
This page is one part of the ClickHouse topic map, which answers a bigger question: do you need ClickHouse, and how do you add it without breaking what works?
In short
- The common mistake is treating the clickhouse vs postgres choice as a winner-takes-all decision; ClickHouse's own documentation recommends keeping Postgres as the system of record and adding ClickHouse for analytics [1][5].
- Postgres is an OLTP database built to guarantee that a block of updates either succeeds or fails in full, which is why it stays the app's database Keep Postgres for transactions and add ClickHouse for analytics [1].
- ClickHouse is an OLAP database built to aggregate over vast datasets quickly, and queries that scan millions of rows finish far faster there [1][6].
- Columnar storage is the mechanical reason: ClickHouse reads only the columns a query needs, while Postgres reads whole rows off heap pages [6][8].
- ClickHouse skips transactions, uniqueness enforcement and cheap in-place updates; primary keys do not enforce uniqueness, so it is a poor system of record [5].
- One public benchmark on a five-table join with 2M orders and 5M line items ran the same query 9x faster on ClickHouse with an identical schema, before denormalizing [2].
- The result for the business is one set of numbers for reports without loading analytical work onto the database that takes your orders.
At a glance
| Fact | Postgres | ClickHouse | Source |
|---|---|---|---|
| Design target | Transactions (OLTP) | Analytics (OLAP) | [1] |
| Storage layout | Row-oriented heap pages | Columnar MergeTree parts | [6] |
| Multi-statement transactions | Yes, ACID | Experimental, not in Cloud | [5] |
| Unique primary keys | Enforced | Not enforced | [5] |
| Updates and deletes | Cheap, in place | Async mutations, expensive | [6][8] |
| Typical compression | 60–80% of original with TOAST | 10–30% of original | [6] |
| Best dataset size | Application state | TBs to PBs | [8] |
The rest of this page takes each row apart and ends with the architecture that most teams land on.
The storage layout decides who wins your query
The storage layout decides which database wins a query, because Postgres stores rows together and ClickHouse stores columns together [6]. Postgres packs rows into heap pages with headers, pointers and padding. Fetching one column means touching the whole row [6]. That locality is perfect when you load a user profile or update an order. It is a liability when you want one metric across a billion events [6].
ClickHouse stores each column in MergeTree parts, sorted by primary key, partitioned by date or category, and compressed per column [6]. A query for the average price reads the price column and nothing else, while Postgres loads order id, customer id and product name into memory even when it needs one column [8]. Predicate pushdown skips whole parts using min/max values in each file, and partition pruning drops irrelevant data before the query engine sees it [6]. Vectorized execution then processes rows in batches across every CPU using the cache [7]; notably, vectorization is a batch-processing execution model, and SIMD is merely one implementation choice for the inner loop rather than being equivalent to vectorization.
That is why a group-by over a large history returns in sub-seconds on ClickHouse while Postgres takes minutes, and the gap widens with concurrency [6]. The same benchmark that showed 9x on identical schema also measured ClickHouse's columnar compression at 3.8x smaller than Postgres for the same data [2]. If that number matters to you, the ClickHouse vs PostgreSQL performance benchmark 2026 breaks down the query shapes that produce it.
Why Postgres falls over on reports
Postgres falls over on reports because analytical queries run for minutes and hold resources that the application needs. Each long-running query blocks replication on a replica, and replica lag grows linearly with query load [6]. Teams on Postgres pay more for storage and compute as dashboards pile up, and the dashboards still time out [6]. The database works hard, the bill grows, and nobody trusts the number that finally appears.
Why ClickHouse can't take the writes
ClickHouse can't take the application's writes because it has no true multi-statement transactions and updates are asynchronous mutations [5][8]. The engine prefers immutable inserts with versioning: old rows are marked and merged later, and real-time updates need engineered workarounds [6]. While changing one field on one row with heavyweight ALTER TABLE…UPDATE mutations means rewriting a whole column [7], ClickHouse now offers lightweight UPDATE using patch parts that do not rewrite entire columns. If ClickHouse powered a dating app, the only match a user would get is a loading modal Consider using a columnar database for analytical workloads.
What the options are, laid out side by side
The options are not two databases but four: Postgres alone, Postgres with an analytics extension, ClickHouse alone, and both together. Postgres is a general-purpose object-relational database with decades of development behind it, and it handles a surprising amount of analytics with the right indexes [3][8]. ClickHouse gives up some of that relational comfort for columnar scan speed at a scale Postgres wasn't built for [3].
| Option | What it is | Good when | Watch out for |
|---|---|---|---|
| Postgres only | Row store as system of record | App traffic dominates, analytics are moderate | Long queries block replicas [6] |
| Postgres plus TimescaleDB or Citus | Extensions that add columnar compression and partitioning | One database, team already knows Postgres | ClickHouse is open source under the Apache License 2.0 [5] |
| ClickHouse only | Columnar OLAP as the main store | Analytics is the product and data is append-only | No transactions or unique keys [5] |
| Postgres plus ClickHouse | Two systems joined by CDC | The app writes rows, reports scan history | Keep Postgres for transactions and add ClickHouse for analytics [1] |
ClickHouse manages a narrower, fast-growing catalog: table engines for Kafka, S3, MySQL and PostgreSQL, plus dbt-clickhouse and Grafana/Superset support [3]. Postgres counters with flexible SQL, customization options and a mature ecosystem [4]. TimescaleDB packages time-series analytics as a Postgres extension, with hypertables, a columnstore and continuous aggregates under a mixed Apache 2.0 and Timescale License [5]. If the real comparison in your head is against a warehouse rather than a row store, the honest take on is ClickHouse better than Snowflake covers that ground.
Which one to choose: the questions that actually decide
Choosing between them comes down to the shape of your workload, not to a speed test. ClickHouse's documentation frames the split simply: Postgres for transactions, ClickHouse for analytics [1]. In practice, four questions settle it.
- Does the application update single rows? If yes, that data lives in Postgres, because updates in ClickHouse are asynchronous and expensive [6][8].
- Is the analytics data large and mostly append-only? Events, logs, metrics and clickstream data written once and read many times are ClickHouse's home ground [5].
- How large is the history? ClickHouse has higher overhead on small datasets, and the MergeTree engine's part management can make it slower than Postgres under roughly 100 million rows [8]. Under 100GB of data, a second database rarely justifies the operational work [6].
- Do reports need sub-second reads over many rows? A dashboard that aggregates over 100 million rows is a clear ClickHouse case [6].
Choose Postgres for transactional data, moderate-scale analytics and data that changes in place [3]. Choose ClickHouse for large-scale aggregation, cheap fast storage and scans over a growing history [3]. Choose both when the app writes individual rows and the business reads aggregates over the same data [5][6].
The signs you've hit the limit
The signs are concrete: a dashboard query runs for minutes, replica lag tracks query load, and the finance sheet no longer matches the dashboard. Those are the moments when the row store is doing a job it wasn't designed for [6]. A single query that once took seconds and now takes minutes is the cheapest signal you'll get.
When one Postgres is enough
One Postgres is enough when analytics stay moderate and the team wants to stay on one system. TimescaleDB or Citus may be enough on their own [5]. Postgres executes window functions and joins adequately on moderate datasets, and it handles transactional guarantees without a pipeline in between [6]. The complexity of CDC and dual systems outweighs the gains at that size [6].
Running Postgres and ClickHouse together
Postgres and ClickHouse run together through a sync pipeline, with Postgres kept as the two-system record of app state and ClickHouse owning analytics [6]. Real-time Change Data Capture (CDC) is the recommended path for most modern cases, because it captures inserts, updates and deletes and keeps ClickHouse fresh without manual work [1]. On ClickHouse Cloud you do this with ClickPipes, whose Postgres CDC connector is fully powered by PeerDB and offered as a seamless native experience—though PeerDB is itself natively integrated with ClickHouse Cloud rather than being an on-prem tool. [1].
- Turn on logical replication in Postgres and capture committed changes.
- Buffer the change stream in Kafka or Redpanda; ClickHouse consumes it in batches, with latency measured in seconds [6].
- Land the rows in MergeTree tables, sorted by the keys your reports filter on [6].
- Validate freshness against the source and compare query results row by row before cutting over [6].
- Cut over dashboards one at a time and keep Postgres as the fallback until confidence is earned [6].
Manual bulk load followed by periodic updates is the simpler alternative for one-off migrations or data that doesn't need real-time freshness [1]. It works, but it puts a delay between a change in Postgres and its appearance in ClickHouse [1]. For the tooling decision itself, the PostgreSQL to ClickHouse migration tool buyer's guide goes deeper.
Querying across both systems
You can query across both systems without copying tables: the ClickHouse PostgreSQL engine exposes Postgres tables as external tables [6]. That lets a report join hot dimension data from Postgres against event history in ClickHouse, and BI tools don't need to know [6]. ClickHouse also publishes pg_clickhouse, a Postgres extension that pushes queries down to ClickHouse [5].
Keep the schema simple on the ClickHouse side
Keep the ClickHouse schema denormalized, because joins there are memory-heavy and often need explicit hints [6]. The default hash join builds a hash table of the right-hand table in memory, and join_algorithm selects other strategies, including a merge join when memory limits are reached [5]. There is no optimization of join order relative to other query stages, so how you write the query matters more than in Postgres [5]. Teams frequently materialize complex joins into flat tables to keep ClickHouse fast [6]. The buying guide on Postgres for analytics vs ClickHouse walks through schema decisions in more detail.
What drives the cost of each path
Cost follows the workload's shape, and the wrong store makes analytics cost more than they should [6]. Postgres is open-source and cheap to start, which suits startups and budget-conscious teams [4]. ClickHouse provides cost-effective analytics options with its open-source and self-hosted versions, reducing initial investments [4][5]. ClickHouse Cloud bills pay-as-you-go for compute and storage, with plans from Basic through Scale to Enterprise [5]. If you're weighing self-hosting, is ClickHouse completely free covers the licensing question honestly.
The bigger cost driver is efficiency. ClickHouse compresses typical event data to 10–30% of original size; Postgres with TOAST reaches 60–80% [6]. Less data on disk means less I/O and less storage billed, which compounds as history grows. Postgres can close some of the gap with a columnar extension, but a row store still pays for the columns it reads and doesn't need [3][6].
Compute cost swings the other way on ingestion. Postgres handles 10–50K rows per second with batching, while ClickHouse ingests 1–2 million rows per second, and ClickHouse prefers larger batches measured in seconds to minutes rather than milliseconds [6]. CDC tools capture change streams from Postgres, and Kafka or Redpanda buffers the events [6][8].
Mistakes that cost you the weekend
The most expensive mistake is migrating the application's tables wholesale into ClickHouse because a benchmark looked good. The engine does provide transaction support rather than none, as ClickHouse documentation describes transactional (ACID) support and experimental transactions, and documents transaction control statements such as BEGIN TRANSACTION, COMMIT, ROLLBACK, and SET TRANSACTION SNAPSHOT., primary keys don't enforce uniqueness, and frequent updates turn into mutations that run later [5][6]. A second costly mistake is running heavy analytics on Postgres and calling it fine while replica lag climbs and finance keeps a parallel spreadsheet [6].
- Treating ClickHouse as a drop-in Postgres. Normalized schemas with frequent joins perform poorly; sort keys and denormalized tables are the idiom [5].
- Skipping the freshness check. A pipeline that says it synced isn't proof; compare results row by row before you cut a dashboard over [6].
- Adopting ClickHouse for a small dataset. Under 100 million rows, engine overhead can make it slower than Postgres [8].
- Expecting instant updates. ClickHouse's async mutations mark old rows and merge them later, so a row you changed may not read back immediately [6].
- Forgetting the serialization costs. Moving JSONB payloads into ClickHouse changes how you query them; the ClickHouse vs PostgreSQL JSONB performance comparison covers the trade-offs.
- Assuming materialized views behave the same. Postgres materialized views need manual refreshes; ClickHouse updates them automatically, which changes how you design incremental reports [7].
What ClickHouse is actually used for
ClickHouse is used for real-time reporting over large, mostly append-only data: telemetry, log data, clickstream events and ETL engines [4][5]. Teams deploy it in telecommunications for passive monitoring, in machine learning work combined with language models, and as an analytics engine behind BI tools [4]. It integrates with tools like Kafka and Tableau, and handles large datasets through cost-efficient aggregation [4]. If you want the full picture before deciding, what ClickHouse is used for collects the common workloads in one place.
One publicly documented migration is worth reading. PostHog's team tried a series of improvised Postgres workarounds for client analytics, found them unsustainable, and eventually migrated client data to ClickHouse [7]. No performance figures are published for that change, so treat it as a confirmation that the split architecture is real and not as a benchmark.
Key terms
OLTP: Online transactional processing is a database design that guarantees a block of updates either fully succeeds or fully fails, which suits application state [1].
OLAP: Online analytical processing is a database design built to query and aggregate over vast datasets efficiently, which suits reporting [1].
Columnar storage: Columnar storage keeps each column separately on disk so queries read only the columns they need [6].
MergeTree: MergeTree is ClickHouse's main table engine, which sorts, partitions and compresses data per column into parts [6].
CDC: Change Data Capture is a process that keeps tables in sync between two databases by replicating inserts, updates and deletes in near real-time [1].
Denormalization: Denormalization is the practice of flattening joined tables into wide tables, the idiomatic ClickHouse pattern for fast queries [3][5].
Mutation: A mutation is ClickHouse's asynchronous update or delete that marks old rows and merges them later [8].
Vectorized execution: Vectorized execution processes data in batches as a batch-processing execution model rather than row by row, improving cache locality and amortizing dispatch overhead, with SIMD being one optional implementation choice for the inner loop rather than a defining feature, and batching does not necessarily mean processing across all CPUs. [7].
Sort key: A sort key orders rows inside a ClickHouse table and lets predicate pushdown skip whole parts of the data [5][6].
Common questions
Is ClickHouse faster than Postgres?
Yes for analytical queries, often by orders of magnitude. The same query on a five-table join with 2M orders and 5M line items ran 9x faster on ClickHouse with an identical schema [2]. Aggregation over 100 million rows returns in sub-seconds on ClickHouse while Postgres takes minutes [6]. Postgres stays faster for single-row reads and writes.
Can I replace Postgres with ClickHouse entirely?
No, not for an application that updates individual rows. ClickHouse's documentation recommends a Postgres database as the system of record with ClickHouse added for analytics [5]. Multi-statement transactions are experimental and not supported in ClickHouse Cloud, and primary keys do not enforce uniqueness [5]. Updates and deletes are asynchronous and expensive [6].
When should I add ClickHouse next to Postgres?
Add ClickHouse when reports aggregate over a large and growing history and Postgres is struggling. Concrete signs: a dashboard query takes minutes, replica lag grows with query load, and storage or compute costs climb as analytics piles up [6]. Append-only event, log and clickstream data is the clearest case [5].
How do I keep ClickHouse in sync with Postgres?
Use real-time Change Data Capture, which is the recommended approach for most modern cases [1]. ClickPipes does it on ClickHouse Cloud and PeerDB does it on-prem, handling initial load plus inserts, updates and deletes [1]. Manual bulk loading with periodic updates is the simpler option when freshness doesn't matter [1].
Does ClickHouse support transactions?
Only in a limited, experimental form. The documentation says multi-statement transactions are experimental and not supported in ClickHouse Cloud [5]. There are no foreign keys, row-level locking or serializable isolation, which is why transactional workloads stay on Postgres [6]. ClickHouse prefers immutable inserts with versioning [6].
Is my dataset too small for ClickHouse?
Possibly. Tables under roughly 100 million rows can perform worse in ClickHouse than in Postgres because of MergeTree overhead and part management [8]. Under 100GB, the operational cost of a second database and a CDC pipeline usually outweighs the gains [6]. TimescaleDB or Citus may be enough at that size [5].
Can I query Postgres data from ClickHouse?
Yes. The ClickHouse PostgreSQL engine exposes Postgres tables as external tables, so you can join hot dimension data in Postgres against event history in ClickHouse [6]. ClickHouse also publishes pg_clickhouse, a Postgres extension that pushes queries down to ClickHouse [5]. BI tools query through one interface and don't see the split [6].
Does ClickHouse handle updates and deletes well?
No, it handles them slowly by design. Updates and deletes are handled as asynchronous mutations that are batched and processed later, which favors throughput over immediacy [8]. Old rows are marked and merged later, and real-time updates need engineered workarounds [6]. Change a column value and the engine rewrites that whole column [7].
References
- Comparing PostgreSQL and ClickHouse
- SQL Optimization Benchmark: PostgreSQL vs ClickHouse
- ClickHouse vs Postgres for Analytics — Honest 2026 Comparison
- ClickHouse vs PostgreSQL (2026) - PeerSpot
- ClickHouse vs PostgreSQL: OLAP or OLTP? (2026)
- ClickHouse vs Postgres: When to Switch to Columnar
- In-depth: ClickHouse vs PostgreSQL - PostHog
- Postgres vs ClickHouse: Differences & Use Cases | Kestra
