Parquet and DuckDB as the Analytical Layer Over Postgres

Offload analytics to columnar Parquet files while keeping Postgres as your operational database.

· 8 min read
Cover illustration for “Parquet and DuckDB as the Analytical Layer Over Postgres”
Headless Analytics · October 26, 2026 · 8 min read · 1,858 words

For API-first and agent-first Supabase teams, Parquet and DuckDB can form a headless analytical backend without an opinionated frontend. The durable design is a governed layer of pre-modeled datasets. Postgres remains the system of record, while APIs, human interfaces, and AI agents consume consistent metrics without sending analytical queries to production.

Why Postgres alone hits a structural ceiling for analytical queries

Postgres stores rows together, which works well for transactional work but makes large analytical scans costly. A query that needs only a few columns still reads from a row-oriented layout, and row headers used for concurrency control and dead tuples from update-heavy tables add to the waste. Indexing cannot fully remove that structural mismatch. An index can narrow a known access path, but ad-hoc exploration across full history often requires broad scans.

That scan also affects the application sharing the server. It evicts hot pages from the buffer cache, competes for I/O, and holds a snapshot open, so a report can slow checkout even when the two use different queries. Concurrent analytical requests put pressure on connection pools as well, and the default max_connections limit is reached quickly without PgBouncer. BRIN indexes on append-only tables, scheduled materialized views, and read replicas address anticipated reporting needs. They do not turn the row-oriented store into a columnar engine for unrestricted historical analysis.

What made a columnar analytical layer beside Postgres technically possible

Three developments made this separation practical without requiring a full warehouse. DuckDB provides a vectorized, columnar, single-process engine that links as a library and reads Parquet natively. It can run inside or beside another process. That gives Postgres teams an analytical executor while keeping the operational database in place, so they no longer have to choose between row-executor column stores and leaving Postgres entirely.

Iceberg tables consist of metadata files and data files on object storage and operate independently of a dedicated table service. A Postgres extension can therefore write Parquet and manifests that other engines can read. S3 and its equivalents provide the shared storage. Postgres, Spark, and Trino can access the same object-storage foundation through HTTP instead of depending on the shared filesystem assumed in the Hadoop era.

Snowflake acquired Crunchy Data in June 2025 and open-sourced pg_lake as version 3.0 under the Apache license in November 2025. Databricks acquired Neon in May 2025 and Mooncake Labs, the team behind pg_mooncake, in October 2025. The DuckDB project produced pg_duckdb alongside DuckLake, whose catalog uses a SQL database such as Postgres, SQLite, or DuckDB. These are different implementations of a now-supported architectural choice.

Three integration paths for connecting Postgres and DuckDB, and what each one trades

DuckDB’s postgres extension is the lowest-commitment entry point. DuckDB attaches a live Postgres database, makes its tables available to queries, and can join them with Parquet, CSV, or DuckDB tables. It works with managed services such as RDS and Cloud SQL without changes to Postgres. Analytical computation moves to DuckDB, but source reads remain. Data must cross the network, and complex operations that cannot be pushed down send more data than needed, so they run more slowly than native Parquet queries.

The pg_duckdb extension runs DuckDB inside the Postgres server process while clients keep using their existing Postgres connection. A dedicated PostgreSQL read replica is the recommended placement, because it isolates the effects of resource-hungry analytics from production. The pg_lake variant instead hosts one DuckDB instance in a separate pgduck_server process to avoid the threading and memory-safety limitations of direct embedding. The pg_lake team credits that separation for production stability.

With pg_lake, CREATE TABLE... USING iceberg creates an Iceberg v2 table with data files on object storage and a metadata pointer in Postgres. INSERT, UPDATE, and DELETE participate in Postgres transactions and write an Iceberg snapshot on commit. The resulting files remain standard Iceberg v2 and Parquet. Other engines can read the table by pointing at its metadata file, independently of the Postgres connection.

Scheduled export creates the most complete analytical query boundary. A job reads new rows once and writes Parquet to object storage, after which queries read those files independently of the live database. The main costs are the production database and object storage, while analytical compute is all but free in this pattern. Freshness is the trade-off. Queries that need recent data must use another path or accept the export lag, and production still has to do the scheduled source read. Across all three approaches, the shared aim is isolation of analytical work, but the completeness of that isolation differs.

Why isolation alone is not enough — the case for pre-modeled, governed Parquet datasets

A dashboard, report, and API can read the same exported rows yet calculate different answers because each reconstructs the business logic independently. Faster execution does not settle that disagreement. Materialized views and ad-hoc Parquet exports make data accessible, but they establish consistent definitions only when their contents encode agreed metrics.

A metrics layer, sometimes called a semantic layer, defines those metrics once in code or governed datasets and serves them consistently downstream. Pre-calculated Parquet datasets fit that design directly. A scheduled computation writes the metric result to Parquet, and DuckDB lets a dashboard, report, API, or agent reuse the same governed result.

This changes the purpose of the export job. Its job is to move rows cheaply and produce analytical datasets whose business meaning has already been agreed on. The cost-optimal and governance-optimal paths then converge around the same separation, with Postgres serving the product and Parquet serving the metrics. The technical boundary needs a definitional boundary too. That becomes more urgent when the consumer is an AI agent rather than a person who can question an ambiguous result.

Why AI agents make a governed analytical layer necessary, not just useful

An agent reading raw production tables does not have the business context it needs to reliably make sense of ambiguous columns or inconsistent definitions. It may write SQL that looks right while answering the wrong business question. Raw access is not equivalent to analytical understanding. Pre-modeled datasets remove the need to infer the metric from the operational schema, giving agents the same definitions that human-facing reports use.

Direct production access also creates an operational and security exposure. Agent queries can use up connection pools, and credentials stored in the agent configuration can bypass row-level security. The recommended boundary is gateway-mediated access that enforces permissions and logs access, directs analytics to governed copies, and limits agents to approved query patterns. Granting access at the start does not control how an agent uses its sources over the course of a task.

The agentic data sandbox addresses this broader need by isolating compute, network access, and data state from production. Governed Parquet datasets queried through DuckDB are a practical implementation of that pattern when those boundaries are enforced. MCP supplies a structured access layer that requires governance. An MCP server that exposes those datasets lets agents ask for metrics through shared definitions instead of writing separate production SQL for each business question.

What analytics backend gives a Supabase team API control without a prebuilt dashboard?

For a Supabase team, this headless backend consists of scheduled metric exports, Parquet on object storage, DuckDB for queries, and a single MCP server exposing the governed datasets. It does not require an opinionated dashboard frontend or a full warehouse. Postgres remains the operational store. Application writes, auth tokens, Realtime channel metadata, and storage metadata stay there, while the analytical layer reads its source data on a schedule.

The export job reads new rows once and produces incremental, repeatable Parquet outputs. Production is not queried again by this analytical path until the next scheduled read. Revenue, activation, churn, and retention are computed with consistent logic before consumers ask for them. The definitions belong in the datasets themselves. This makes the backend useful for raw API access without requiring each application interface to implement its own interpretation of the metrics.

A single MCP server then exposes the datasets to dashboards, reports, Slack digests, and AI agents. Claude and a dashboard can answer from identical definitions while presenting the result differently. Agents receive no production database credentials. Their access is read-only and scoped through the MCP layer, keeping analytical exploration separate from production connection pools and leaving those pools available for the application. For usage analytics inside an agent, the integration target is this governed backend.

Teams still need to monitor the scheduled read on Supabase. The pg_stat_statements and auto_explain tools find slow queries before they become export bottlenecks. The Supabase Metrics API exposes metrics in a monitoring-compatible format covering CPU, IO, WAL, connections, and query statistics. Production health remains independently observable through these tools. Separating analytical queries removes repeated reporting load, but it does not make the source extraction invisible to the operational database.

Where this architecture fits and where it runs out of road

The governed Parquet-and-DuckDB pattern fits analytical data measured in hundreds of gigabytes to low terabytes. It serves dashboards and scheduled reports well when a few minutes of lag is acceptable, particularly for teams without a dedicated data engineer. Those conditions define a useful operating range. They do not make an external layer the first response to every slow report.

Postgres-native changes remain the simpler answer when an index, partition scheme, or concurrently refreshed materialized view resolves the problem at zero additional infrastructure cost. Add the external layer only when those measures stop being enough. A point lookup on a Postgres heap table is sub-millisecond, while the same lookup on an Iceberg table on object storage takes tens of milliseconds at best. Applications needing both retain heap-table lookups and use Parquet for analytical scans.

Concurrency and freshness create a separate limit from storage size. DuckDB on a single node is not a multi-user concurrent query server, so many simultaneous ad-hoc analysts with strict freshness requirements call for a dedicated analytical server. Multiple terabytes or sub-second freshness requirements also signal that the pattern needs to evolve. Extensions and export schedules have practical limits. Most early and growth-stage Supabase teams still fit within the range this architecture serves, so adding infrastructure too soon costs them money for something they do not yet need. These teams need to set up governed metrics now and can leave work on other execution systems until they need them.

The architectural decision — Parquet and DuckDB as a governed layer, not a performance patch

When DuckDB is treated as a performance patch, query speed guides the design. When it is treated as metrics infrastructure, the dataset contract guides the design and execution serves that contract. The distinction shapes what gets exported. Raw copies leave business interpretation to consumers, while pre-modeled datasets encode the definitions that APIs, reports, and agents are meant to share.

That contract also separates access-layer growth from the database’s transactional role. The MCP 2026-07-28 specification introduced a stateless protocol design that lets the access layer scale horizontally without session-pinning concerns. Scoped permissions, approved query patterns, and consistent definitions remain properties of the governed implementation. For Supabase teams, the durable division is Postgres handling transactional integrity, row-level security, and connection management, while the analytical layer owns the shared meaning of the numbers.

More in Headless Analytics