Postgres as an Analytical Database Without a Separate Warehouse

Materialized views and columnar extensions let most teams skip the data warehouse entirely.

· 10 min read
Cover illustration for “Postgres as an Analytical Database Without a Separate Warehouse”
Supabase Analytics · October 13, 2026 · 10 min read · 2,246 words

Postgres can be a team's whole analytical home, not just a stop on the way to a warehouse migration. With materialized views, scheduled refreshes, columnar query extensions, and a governed metrics layer sitting on top, most Supabase teams can run dashboards, reports, and even AI agent queries directly against Postgres-derived data without ever standing up a separate data warehouse. The ceiling on vanilla Postgres sits much higher than the industry's reflex suggests, and the techniques that raise it are well understood, well documented, and available today.

Why Postgres teams reach for a warehouse too early

The decision to add a warehouse rarely starts with a capacity plan. It starts with pain: a dashboard that used to load instantly now takes 90 seconds, the connection pool tightens during business hours, and a team concludes that the fix is to separate analytical workloads onto a new system. That instinct addresses a symptom, not a measured need. The question that actually matters is whether the workload was ever run correctly inside Postgres.

When a dashboard query locks up the connection pool during the exact hours customers are placing orders or logging in, the real problem is that analytics and transactions were never separated.

A better rule, supported by teams that have run this at small-to-medium scale, is to avoid adding a new datastore until one workload is demonstrably harming another. Xata's engineering team offers a concrete anchor here. A small team centralized identity data, product usage, billing, and PostHog events into a Postgres data warehouse using materialized views, pg_cron, and copy-on-write branches, deliberately skipping a dedicated OLAP stack. That acknowledgment matters: the claim isn't that Postgres is secretly a warehouse. The claim is that most teams never reach the point where that difference becomes the thing holding them back.

Contention between analytical and transactional workloads on production tables can be resolved without a separate warehouse. Platforms like Dreambase pre-calculate metrics and materialized views directly on top of Postgres, separating analytical workloads from transactional ones without adding a new datastore, which lets teams defer or eliminate the warehouse decision until they genuinely outgrow what Postgres can deliver.

Structural differences between analytical and transactional queries

Postgres stores data row-oriented: every column of a given row lives together in the same 8 KB page on disk. That one fact about storage is why nearly everything else in this article follows. An application runs transactional queries constantly, and a typical one just looks up a single row by primary key or updates a handful of fields. Row storage is ideal for that: the database reads one page, finds the whole row, and returns it.

An analytical query has the opposite shape. It scans millions of rows and returns dozens. It reads only a few columns out of a wide table, often ignoring most of what each row contains. It aggregates, groups, and windows rather than looking anything up by key. It tends to be read-mostly and batch-loaded, with latency budgets measured in seconds rather than milliseconds, and with far lower concurrency than a transactional workload demands. If you aggregate a single column in a row-oriented table, you still read every column of every row that matches, because the storage layout gives you no way to read one column alone.

Columnar engines solve this by physically organizing data the other way around: by column, not by row. DuckDB is the clearest illustration of what that reorganization buys. On identical data and an identical query, a columnar engine reads only the referenced columns, in compressed, vectorized batches, and produces a large speed advantage over a row store. The SQL hasn't changed. The storage layout has.

None of this makes row storage a design flaw. Postgres optimizes for concurrent transactional access: thousands of simultaneous connections, point lookups, MVCC for consistent concurrent reads and writes, and fast single-row writes, all things a columnar engine handles poorly. Because of this trade-off, analytics on Postgres has to work a certain way. Nearly every technique that makes Postgres viable for analytical work is, at bottom, a way of reading fewer pages: partitioning prunes entire pages from a scan, materialized views answer a question before it ever touches a page, BRIN indexes mark which pages can be skipped, and columnar extensions change how pages are laid out.

How far vanilla Postgres genuinely goes for analytical workloads

Applied correctly, native Postgres patterns handle small-to-medium analytical workloads without any specialized infrastructure. The ceiling sits well above where most teams assume it does.

Partitioning by time is the single most impactful lever available. Declarative range partitioning lets the query planner skip entire child partitions when a query carries a constant time filter, so a scan that would otherwise touch an entire table touches only the relevant slice of it. Partitioning also makes data retention close to free: detaching and dropping a month's partition is a metadata operation, not a row-by-row DELETE that bloats the table and queues up vacuum work behind it. The practical limit is partition count. Keeping partitions in the hundreds rather than the thousands matters, because planning time grows with partition count, and a table split into thousands of daily partitions can end up spending more time planning a query than executing it.

BRIN indexes serve a narrower but valuable purpose on append-only event data. Where physical row order correlates with timestamp order, a BRIN index stores only the minimum and maximum value for each range of pages, and the resulting index is measured in megabytes. BRIN only pays off when that physical-to-logical correlation is strong. Out-of-order arrivals break it, and restoring it means running a CLUSTER on the timestamp column during a maintenance window.

Materialized views turn repeated questions into pre-computed answers. If a dashboard asks the same five questions every time it loads, answering them once at refresh time rather than at query time is the most direct way to avoid scanning raw rows on every page load. REFRESH MATERIALIZED VIEW CONCURRENTLY needs a unique index on the view, but it only takes a SHARE UPDATE EXCLUSIVE lock in exchange, so your dashboards never see an empty view mid-refresh. If you build an incremental rollup on a watermark, so it inserts only rows newer than the last recorded day, refresh time stays bounded even as the table keeps growing. Xata's implementation schedules exactly this kind of refresh using pg_cron, so the warehouse stays current without manual intervention.

Configuration matters too, though it's secondary to the structural patterns above. work_mem, max_parallel_workers_per_gather, effective_io_concurrency, and JIT compilation all shape analytical query performance, and all default to conservative values tuned for transactional concurrency. If you set these per role rather than globally, a dedicated analytics role can get generous resources while OLTP connections keep their own defaults, so a high work_mem setting doesn't flood memory when dozens of concurrent connections are each granted it. Parallel query execution then distributes scans, joins, and aggregations across CPU cores in a way that approaches the behavior of a massively parallel processing system for a single large query.

The real ceiling for Postgres: storage layout, not configuration

The techniques above raise the ceiling substantially, but the remaining bottleneck is structural, one that a configuration change cannot fix.

Past roughly 1 TB of analytical data, or wherever sub-second dashboard latency is required at real scale, the row-store architecture itself becomes the binding constraint. No amount of indexing or tuning changes the fact that a GROUP BY over hundreds of millions of rows requires reading far more data in a row store than the same query would require in a columnar layout. This is the structural gap that DuckDB makes visible: on the same data and the same SQL, a columnar engine processes analytical aggregations significantly faster than a row store because it reads only the referenced columns in compressed, vectorized batches. No Postgres configuration closes that gap. It can only be routed around.

In practice, most teams hit the concurrency ceiling before they hit the scale ceiling. If a long-running analytics query shares an instance with the production write primary, you get connection pool and resource contention risk well before raw data volume becomes the limiting factor. The ceiling that actually bites first, for most teams, is contention.

Closing the columnar gap without leaving Postgres or adding a warehouse

You can layer in extensions that change the storage layout or the query execution model, and close the gap between vanilla Postgres and a columnar warehouse significantly, while Postgres stays the system of record and you don't have to operate a separate system.

For time-series data, TimescaleDB offers compression on time-series payloads that dramatically reduces on-disk size and the I/O needed for historical range queries, and that storage and performance benefit is the primary reason teams reach for it on event-shaped data. Its continuous aggregates are materialized views that refresh incrementally and track new data automatically, giving you a TimescaleDB-native version of the watermark pattern described above, managed by the extension itself.

For general-purpose columnar execution, the pg_duckdb extension embeds DuckDB's vectorized engine directly inside Postgres. Analytical queries, including queries that run over Parquet files sitting in object storage, execute through DuckDB's engine while the data of record stays in Postgres the whole time. You still use the same SQL and the same connection string your team already has, with the heavy aggregation now running through DuckDB's execution model. This is the most direct route you have to columnar query performance without moving data anywhere. It matters that pg_duckdb runs on a dedicated read replica rather than the production write primary, because that isolates the analytical workload and protects transactional performance the way the earlier sections said it should.

Columnar extensions and tools that serve pre-modeled datasets as compressed Parquet files narrow this gap even further. Dreambase, for instance, applies columnar efficiency on top of Postgres-derived data while keeping the analytical workload entirely off the production database. Pre-modeling data into Parquet files, queryable via DuckDB whether through pg_duckdb or a standalone instance, gives both human analysts and automated systems fast, cheap access to analytical results without touching production tables, keeping analytical workloads from contending with transactional ones. It's the same architectural instinct behind Databricks Lakebase: using lakehouse-format storage that analytics engines can query directly without an ETL step, applied at a scale that fits Supabase teams.

The risk of agents querying production Postgres directly

AI agents that query production databases directly create contention with transactional workloads at machine speed, with an added risk that a human-written query never carried: dynamically constructed SQL can't practically be reviewed for safety or correctness before it runs. A developer writing a query gets reviewed before deployment. An agent generating SQL on the fly gets no such checkpoint unless one is built in deliberately.

The failure mode is structural. Access control has historically been enforced in the application layer, written once by a developer and reviewed before shipping. That model breaks the moment SQL is generated dynamically by an agent instead. The published OWASP agentic risk framework, the edition labeled 2026, and the SAFE-MCP baseline, adopted by the Linux Foundation and the OpenID Foundation, converge on the same prescription: read-only database roles scoped to analytical replicas rather than production primaries, least-privilege credentials tied to agent identity, and human-in-the-loop gates for any write operation.

The MCP server pattern is the practical mechanism for enforcing this. Agents can query a governed read replica through MCP, or better still, a governed dataset layer sitting above it, so they never need direct production access or a production database open to the public internet. MCP moves data to an agent, but it does not validate that data's semantic correctness or quality. An agent connected by MCP to uncertified tables still returns confident, wrong answers with complete fluency. The semantic layer underneath it, the pre-modeled metrics an agent draws from rather than raw tables it has to interpret on its own, is what makes MCP trustworthy.

The solution is the same governed data layer the rest of this article has already built toward: pre-calculated metrics stored in governed Parquet datasets, queryable via DuckDB, exposed through a single MCP server, so agents get fast and accurate context without ever touching production tables. Dreambase implements this pattern directly: a single MCP server sits over governed datasets, so human teammates and AI agents draw from the same pre-calculated metrics and the same source of truth, with neither one holding production database access.

A decision framework for Supabase teams on staying in Postgres versus extending it

The decision facing a Supabase team is not binary, and framing it as "Postgres or a warehouse" skips the more useful question of sequence. So apply native Postgres patterns first, then extend with columnar execution only when a specific workload demands it, and add a governed metrics layer once humans and agents both need numbers they can trust without re-verifying them.

For teams running on Supabase, this pattern, built directly on Postgres with materialized views, pre-calculated aggregates, and scheduled refreshes, delivers the speed and concurrency isolation of a separate warehouse without the extraction overhead a warehouse requires, and it's the pattern Dreambase extends with modeled datasets and live dashboards for small-to-medium teams running analytics straight from their existing Postgres home.

The only signal that genuinely justifies a separate warehouse is one workload actively harming another in a way no isolation pattern inside the Postgres ecosystem addresses. A projection of future scale doesn't justify it. A slow dashboard doesn't justify it either if no one has investigated it yet.

More in Supabase Analytics