HomeDataClickHouse

ClickHouse · When Postgres is not enough

Your dashboards got slow as your data grew

Postgres for analytics works until reports slow the app or summary tables pile up. Learn when adding an analytics database beside it pays off.

Don't want to read the whole article?

No problem. We put everything in a 1-minute video, so you get the full idea fast.

By submitting, you agree that Sivaro may contact you about this topic.

Your dashboards got slow as your data grew
Your dashboards got slow as your data grew Your dashboards got slow as your data grew

Tuesday morning standup: the finance dashboard that loaded in two seconds now spins for forty, and the app's checkout page feels sluggish every time someone runs the monthly report. That is the moment teams start asking about Postgres for analytics. Postgres is enough until reports slow down the app or need a pile of summary tables. Then add an analytics database beside it. This page explains why that happens, what the options are, and how to decide without breaking what works.

In short

  • The mistake most teams make is adding indexes and materialized views to the app's Postgres and calling it an analytics fix, when the real problem is that analytical scans compete with checkout for the same CPU and memory.
  • Postgres handles analytics fine at small and medium data volumes, under 100GB, and degrades beyond hundreds of gigabytes because row storage, tuple-at-a-time execution and row-level MVCC are built for transactions, not scans [2].
  • There are at least three ways to use Postgres for analytics: sync into an analytical store, embed an engine in Postgres, or change how Postgres stores data [1].
  • Extensions that run the analytical engine on the Postgres host make each query faster but do not give the server more resources; under load they can cost transactions 18–58% of throughput [3].
  • pg_clickhouse keeps the transactional workload nearly untouched, changing OLTP throughput by less than 2% under analytical load in vendor tests [3].
  • The clean split is to keep Postgres for the app and add ClickHouse beside it for reports, fed by a sync pipeline, when the warning signs show — the position this page defends and the ClickHouse topic map expands.
  • The business result: dashboards come back in seconds and the checkout page stays fast, because the report load no longer runs on the database that takes orders.

At a glance

Question Short answer Source
Where does plain Postgres stop being enough? Comfortable under 100GB; pain beyond hundreds of gigabytes for analytical workloads [2]
How many ways are there to add analytics to Postgres? At least three categories: external store sync, embedded engine, storage change [1]
Which option leaves transactions fastest? pg_clickhouse, under 2% OLTP throughput change under analytical load in vendor tests [3]
Which options run compute on the Postgres host? pg_duckdb and pg_lake [3]
What does pg_lake accelerate? Iceberg tables and files, not heap tables [3]
What is the safest default? Keep analytics in Postgres while there is headroom; move out when queries cost transactional latency [3]

Why the app gets slow when the reports run

The app gets slow because analytical queries and transactional queries share one server, and Postgres has no built-in way to give transactions priority. A report that scans tens of millions of rows holds CPU, memory bandwidth and I/O for as long as it runs. Checkout waits behind it. The dashboard gets slower as data grows not because Postgres is badly designed but because the same architecture that makes it excellent at transactions makes it expensive at scale for scans [2].

Row storage and row-level MVCC

Postgres stores rows, not columns. A report that needs three columns out of forty still reads whole rows off disk. Row-level MVCC keeps multiple versions of each row for concurrent transactions, which is exactly what an app needs and exactly what a scan does not. These are features for transactions that become liabilities for analytics [2].

Forced read-only mode

When transaction ID wraparound approaches, Postgres forces read-only mode. Analytics pipelines that need long-running batch jobs stop, SLAs slip, and the business impact multiplies. The forced read-only mode shuts down analytics at the worst moment [2]. This is the failure that turns a slow dashboard into an outage.

The summary table spiral

The usual first fix is materialized views. They work until the reports ask new questions that the views do not cover. Then you add another view, another refresh job, another index, and a pile of summary tables that nobody fully understands. Each refresh competes with the app too. The pile grows faster than the data does.

The options, compared honestly

There are at least three different ways to use Postgres for analytics, and each is a distinct category of solution, not a setting you flip [1]. The choice comes down to one question: where should the analytical compute run [3]?

Sync out to an analytical store

Postgres replicates its data in real time to an external analytical database or lakehouse. Queries run against that system directly, bypassing Postgres. This needs a replication or CDC solution that captures changes from Postgres and applies them on the analytical side. Supabase ETL, Fivetran and Decodable are examples from this category [1]. ClickHouse sits naturally here: the scans and aggregations run on hardware sized for analytics alone, and Postgres keeps doing transactions [3].

Embed an engine inside Postgres

pg_duckdb embeds DuckDB into Postgres, and pg_lake runs DuckDB in a sidecar process called pgduck_server that talks to Postgres during query execution [1]. Both make individual analytical queries faster. Neither gives the server more resources. A vectorized engine might finish a scan ten times faster, but while it runs it uses the cores, memory bandwidth and I/O that transactional queries also need [3]. pg_lake accelerates Iceberg tables and files, not heap tables; to analyze OLTP data with it you copy that data into Iceberg yourself [3].

Change how Postgres stores data

TimescaleDB, Citus columnar and AlloyDB's columnar engine change how Postgres stores data rather than where the compute runs [3]. Columnar storage helps scans, but the compute still lives on the same server, so the contention problem shrinks without disappearing.

The comparison

Option Where compute runs Transaction impact under analytical load Best fit
Read replica or plain Postgres Same server or a copy None on primary, but reports still bounded by one machine A few reports a day over a few million rows [3]
pg_duckdb / pg_lake Postgres host Large: 18–58% throughput drops in vendor tests [3] Ad-hoc queries where transactional latency has slack
pg_clickhouse with ClickHouse Separate cluster Under 2% in vendor tests [3] Reports that scan tens of millions of rows or run often [3]

| Columnar storage (Citus, TimescaleDB, AlloyDB) | Same server | Moderate; scans cheaper but compute shared | Teams already on those platforms |

When Postgres for analytics is still the right call

Postgres for analytics is the right call while the data is small and the reports are few. Postgres works exceptionally well for analytics at small to medium data volumes, under 100GB, with the advantage of supporting transactions, real-time analytics and light warehousing on one system [2]. If the business runs a handful of reports a day over a few million rows, plain Postgres or a read replica will do, and pg_clickhouse is the wrong tool [3].

A read replica is the cheapest step up. Point the reports at the replica, keep the primary for the app, and the checkout page stops waiting on the monthly report. The replica is still one machine, so the ceiling arrives with data growth, but it buys time without new infrastructure.

When this is the wrong choice

Adding a separate analytical database is the wrong choice in several concrete cases, and each has a cheaper answer.

  • The workload is a few reports a day over a few million rows. Plain Postgres or a read replica will do; skip the separate store entirely [3].
  • The analytical engine would run on the Postgres host and the primary cannot restart. On a 4 GB instance with default settings, a repeated 5-million-group aggregation pushed a pg_duckdb backend past the memory limit, the kernel killed it, Postgres treated the killed backend as a crash, terminated every connection and ran crash recovery [3]. One analytics session took the whole database offline for transactional clients. If the app cannot absorb that risk, keep the engine off the primary [3].
  • The data lives in a lakehouse and the team wants to query it in place. pg_lake accelerates Iceberg tables and files directly, and rewriting those parts of a query into a DuckDB-compatible form is its job [1]. A separate store would mean copying data that is already queryable.
  • The team is small and the budget is fixed. Every new store adds a sync pipeline to monitor, a schema to keep aligned and a system to upgrade. If nobody owns that work, the sync will rot and the dashboards will drift from the app. Stay on Postgres and revisit when someone owns the pipeline.

How it works: pushing the scans off the app server

How it works: pushing the scans off the app server

The clean split works by pushing the heavy work to a system built for it. pg_clickhouse is an Apache-2.0 Postgres extension that lets you query ClickHouse tables from Postgres and pushes as much of each query as it can down to ClickHouse [3]. Postgres keeps planning the query and converting results, but the scans and aggregations happen elsewhere [3]. That "elsewhere" scales across nodes and is sized for analytics alone [3].

The path for the data is the sync pipeline. The source reads changes from Postgres, applies them to the analytical store, and both systems see the same rows within a lag the team sets and monitors. The analytical store holds a reporting copy, not the system of record. The app keeps writing to Postgres and never reads the analytical store directly.

For teams weighing the two engines head to head, the data engineer's buying guide on Postgres vs ClickHouse walks through the workload shapes each one fits. The wider question of what ClickHouse is used for covers the real-time analytics side that Postgres struggles with at scale.

Running it: the pipeline is the product

Running the split means owning a pipeline, and the pipeline is where most of the operational work lives. Treat it as a product with an owner, a lag target and an alert when it falls behind. The rest of this section is the working checklist.

Sync

Set up change data capture from Postgres to the analytical store. The requirement is a replication solution that captures changes and applies them on the analytical side [1]. Test replays on a copy before pointing production at it. Decide which tables replicate and exclude the ones nobody reports on, because every replicated table is lag you have to watch.

Schema drift

When someone adds a column to a Postgres table, the analytical copy must accept it. Run a check in CI that compares the two schemas, and fail the build when a new column is not in the sync config. Silent drift is how the dashboard starts showing a stale total that nobody can explain.

Query routing

Keep the reporting queries in the analytical store and the app queries in Postgres. Mixing them defeats the purpose of the split. If a report queries Postgres directly "just this once", it is back on the app's server, competing with checkout.

Monitoring

Track sync lag, failed batches and query times per dashboard. Set an alert on lag so the team hears about it before finance does. A pipeline that falls behind quietly is worse than a slow dashboard, because the numbers look fine and are wrong.

What drives the cost

Cost in this setup comes from three places: the analytical cluster, the sync pipeline and the people who run both. Keeping the workloads separate is what keeps the cost predictable, because each system is sized for its own job.

The analytical store scales independently of Postgres [3]. That means you can add capacity for a busy reporting week without touching the database that takes orders, and you can keep the transactional instance small. A same-host engine does the opposite: it spends the app server's existing capacity on scans, so the "free" analytics arrives as slower transactions [3].

The sync pipeline costs ongoing attention. Every table, every schema change and every lag alert is work. A small team should price that work in hours before choosing the split, and should count the cost of a second system to upgrade and back up.

What to expect: a separate analytical cluster plus a sync pipeline is more moving parts than one Postgres. The trade is that report load stops competing with the app, and each system is sized for the job it does [3]. If the report load is small, that trade is not worth making [3].

How to check in your own system

Four signs say the analytics have outgrown Postgres. Check them this week, cheapest first.

  1. Measure how much analytical queries cost transactions. Compare p95 latency on the checkout path during a report run against the same metric on a quiet hour. A visible jump says the scans are competing with the app. Source measurements put the same-host engine cost at 18–58% of throughput under analytical load [3].
  2. Check data volume against the comfortable range. Postgres analytics is comfortable under 100GB and painful beyond hundreds of gigabytes [2]. Look at the size of the tables the reports scan, not the whole database.
  3. Count the summary tables. If the schema has a pile of materialized views and refresh jobs that nobody fully owns, the workaround has become the workload. Each refresh is also a query on the app server.
  4. Check for forced read-only events. Search the Postgres log for read-only transitions. Forced read-only mode shuts down analytics and interrupts pipelines [2].

The cheapest check this week is the first one. No new infrastructure, no migration plan: run the heaviest report during a quiet period and again during peak, and compare the app's response time. If the peak run moves the numbers, the answer is already decided.

Common mistakes

The same mistakes show up in team after team, and each one has a fix.

  • Tuning Postgres instead of splitting the load. Indexes and materialized views optimize for a pre-defined set of queries; they do not give the server more resources [1][3]. If the problem is contention, tuning moves the cost around.
  • Running the analytical engine on the primary. MotherDuck recommends keeping pg_duckdb off the primary, and pg_lake's docs recommend limiting pgduck_server on servers with a busy Postgres workload [3]. The crash case above is what happens when that advice is skipped [3].
  • Forgetting the memory caps. pg_duckdb and pg_lake both expose memory and thread caps, and sizing duckdb.max_memory against total memory and expected concurrency is the fix [3]. The alternative is a killed backend and crash recovery [3].
  • Assuming pg_lake accelerates heap tables. It accelerates Iceberg tables and files; a join between a heap table and an Iceberg table puts the join back on Postgres [3].
  • Letting the dashboard read Postgres "just this once." One report on the app server is one report competing with checkout.

Key terms

CDC (change data capture): a replication method that reads changes from Postgres as they happen and applies them to another system.
pg_clickhouse: an Apache-2.0 Postgres extension that queries ClickHouse tables from Postgres and pushes as much of each query as it can down to ClickHouse [3].
pg_duckdb: an extension that embeds DuckDB into Postgres so analytical queries run through a vectorized engine on the same host [1].
pg_lake: a set of extensions and components that query and modify Iceberg tables and other lakehouse formats from Postgres, with DuckDB in a sidecar process called pgduck_server [1].
MVCC: Postgres's row-versioning scheme that keeps multiple versions of a row for concurrent transactions; excellent for the app, expensive for large scans [2].
Materialized views, indexes, partitioning, and other built-in Postgres capabilities are typically used to optimize Postgres for a pre-defined set of analytical queries [1].
Sync lag: how far the analytical copy trails Postgres; the number to alert on.
Wraparound: the transaction ID counter rolling over, which forces Postgres into read-only mode and shuts down analytics [2].

Common questions

Is Postgres good enough for analytics?

Postgres is good enough for analytics at small and medium volumes, under 100GB, where it supports transactions and light analytics on one system [2]. It gets painful beyond hundreds of gigabytes because row storage, tuple-at-a-time execution and row-level MVCC are built for transactions [2]. The answer depends on the size of the tables your reports scan, not the size of the whole database.

What are the ways to use Postgres for analytics?

There are at least three categories: sync data out to an external analytical store, embed an engine like DuckDB inside Postgres, or change how Postgres stores data [1]. Each has different trade-offs for transactional impact and operational work. The choice comes down to where the analytical compute should run [3].

Does pg_duckdb slow down the app?

pg_duckdb runs the analytical engine on the same host as Postgres, so it uses the same cores, memory bandwidth and I/O that transactions need [3]. In vendor tests, same-host options cost transactions 18–58% of throughput under analytical load [3]. With default settings on a 4 GB instance, a heavy aggregation was killed by the kernel and took every connection down with it [3].

Why is pg_clickhouse different from pg_duckdb?

pg_clickhouse pushes supported query operations down to a separate ClickHouse server or cluster, so the heavy scans run on hardware that scales independently of Postgres [3]. pg_duckdb runs the engine on the Postgres host, which makes it quick to adopt but shares the server's resources [3]. In vendor tests pg_clickhouse changed OLTP throughput by less than 2% under analytical load [3].

Do I need a separate database, or can a read replica work?

For production analytics that must not slow down your transactional workload, or that will outgrow one machine, use pg_clickhouse with data replicated into ClickHouse [3]. A separate analytical store is for reports that scan tens of millions of rows or more, run often enough to affect transactional latency, or need to scale independently of Postgres [3]. The replica is still one machine, so its ceiling arrives as data grows.

How long does an analytics migration take?

Research cited in one source suggests teams need three to six months to plan and execute an analytics migration [2]. That estimate covers planning, pipeline work and cutover, and it is why early detection of the warning signs matters. If a small team cannot spare that time, staying on Postgres and adding a read replica is the safer path for now.

Can I keep reporting on Iceberg tables without copying the data?

pg_lake lets you query and modify Iceberg tables and other lakehouse formats directly from Postgres, with DuckDB accelerating the scans [1]. It does not accelerate heap tables, so joins between ordinary Postgres tables and Iceberg tables put the join back on Postgres [3]. If your reporting data already lives in a lakehouse, this can avoid a copy.

What is the warning sign that I should move analytics out?

The clearest sign is a report run that visibly slows the app's transactional path. If checkout latency jumps during a report, the workloads are competing, and the fix is to move the scans off the app server [3]. A pile of summary tables and refresh jobs that nobody fully owns is a close second.

References

References
  1. Postgres for Analytics: These Are the Ways | Just Postgres
  2. Why PostgreSQL Fails at Scale for Analytics: Architecture Deep Dive
  3. Best Postgres extensions for analytics in 2026: pg_clickhouse, pg_duckdb, pg_lake

Want to talk this through?