DuckDB as the Query Engine for Agentic Analytics
Embedded DuckDB isolates each agent's queries from production systems and shared infrastructure.

DuckDB's defining trait is architectural: the engine runs inside the process that calls it, rather than as a separate server a client connects to. That one fact explains why DuckDB has become the default query engine for agentic analytics, and this piece lays out how that architecture plays out from a single embedded instance to a full production workflow.
DuckDB's Embeddability: The Architectural Trait That Matters for Agents
Most query engines assume you have a cluster sitting somewhere else, waiting for connections. A client opens a session, sends a query over the network, then waits for a result set before it closes the session. DuckDB inverts that model. It runs inside whatever process invokes it, so the engine travels with the application instead of the application reaching out to shared infrastructure. If you are a human analyst running occasional reports, that distinction might be academic. For an agent, it is the whole story.
An agent is not a person running a query once an hour. An agent is a process that might issue dozens or hundreds of queries in a short burst, chained together as it reasons through a task. When agents drop into a centralized architecture, they just become one more client competing for a shared connection pool, a shared query queue, shared compute. The August 2026 DuckDB ecosystem newsletter names the direction in blunt terms: "giving every agent its own embedded DuckDB." That is a description of a deployment pattern, and it says that isolation, not just speed, is the reason DuckDB fits the agent use case. When each agent runs its own engine, one agent's query load cannot starve another, and it cannot reach backward into production systems it was never meant to touch.
There is a second advantage that compounds the first. DuckDB speaks SQL natively, and agents built on large language models already reason toward SQL as a natural output format. An agent writes a question in natural language, then produces a SQL query, and the engine it hands off to takes SQL directly, with no custom query language and no translation layer to lose or distort the agent's intent. So that query can be logged exactly as written, rerun exactly as logged, and tested exactly as rerun. The query layer becomes something an engineering team can audit after the fact, which matters more for agents than for humans, because nobody is sitting next to the agent watching it work.
What agent-local compute looks like in practice
Embeddability, carried to its logical end, produces agent-local compute: each agent runs its own DuckDB instance, queries its own slice of governed analytical data, and returns an answer without waiting on shared infrastructure. Joe documented this architecture in the August 2026 newsletter, and it builds this out concretely. Each agent, referred to as a peer, gets a dedicated embedded DuckDB instance. Peers talk to each other directly over loopback TCP ports rather than through a central broker, and what they exchange are "immutable analytical slices," not raw queries or open connections.
Each of those slices carries its own identity, called a SliceRef, built from a catalog_id, a dataset name, a DuckLake snapshot_id, a contract_digest tied to a semantic model defined in a modeling layer, and a slice_digest. That amount of structure around a piece of data might look like overkill until you consider what it buys: immutability. A slice an agent receives today is the same slice it would have received yesterday. No schema drifts underneath it, no value changes between one run and the next, and that stability is what makes an agent's output something a human can later check against the data that produced it.
Immutable, agent-local slices also solve a concurrency problem that centralized clusters handle badly. Agents chaining results together need fast turnaround at every step, and a shared analytical cluster forces them into the same queues that batch reports and dashboard refreshes sit in. Decentralizing the compute removes the queue entirely: each agent's query runs against its own engine, on its own slice, with no other agent's workload in the way.
None of this would scale past small datasets without changes to how DuckDB handles I/O, and the August 2026 newsletter points to exactly that work landing in version 2.0: separate thread pools for regular workers and asynchronous I/O, a read-ahead queue, and memory governance that fetches data proactively and heads off out-of-memory failures before they happen. That groundwork is what turns agent-local compute from a pattern that works for toy queries into one that holds up against real analytical datasets.
Why Production Databases Must Be Physically Off-Limits for Agents
Software permissions on a live production database were designed around a threat model built for humans: a person with a role, a set of grants, and intentions a system can mostly assume are benign unless proven otherwise. Agents break that assumption in a specific and well-documented way. Prompt injection is the top entry in the OWASP Top 10 for LLM Applications because a large language model processes instructions and data over the same channel. A query result returned to an agent is data, but nothing stops its contents from being read by the model as an instruction. If that agent holds any write permission at all, an attacker who can get a malicious string into a queried table has a path to exploit it, using a grant that was valid and properly issued.
A read-only grant does not have that failure mode. An injected instruction riding through a query result has nothing to attach itself to if the only thing the agent can do is read. That is why the correct control for agents is physical separation from production, not a role-based permission scheme layered on top of a connection that could still, under some configuration, write. Pointing the agent at a read-only replica makes a DROP, DELETE, or UPDATE impossible regardless of what instruction the agent has been fed. The constraint comes from the architecture itself, not from a policy an administrator wrote down and hopes gets enforced correctly every time.
The same logic holds at the configuration level for DuckDB-WASM deployments, where agents may run inside a browser. After the engine starts, the recommended sequence is to run SET autoinstall_known_extensions = false, then SET autoload_known_extensions = false, then SET lock_configuration = true, with SET enable_external_access = false applied separately to shut off file and network access. These configuration-level locks are set once, and they remove categories of behavior from the engine at the architectural level, before runtime checks ever come into play. The pattern across both cases, replica and browser-based engine, is the same: build constraints into the architecture an agent cannot query its way around, rather than trusting a policy it might be talked into ignoring.
Governed datasets as the layer that makes agent queries trustworthy, not just safe
Physical isolation keeps an agent from damaging production, but it says nothing about whether the agent's answer is correct. An agent pointed at a pile of un-certified, un-modeled tables will return a fast result every time, and that result can be wrong in ways nobody notices until a decision has already been made on top of it. Safety and correctness are separate problems, and an architecture that solves only the first one has solved half the job.
The fix is to change what an agent is allowed to query. Instead of handing an agent a raw table and trusting it to interpret column names and joins correctly, the right unit of input is a dataset that has already been modeled, with a semantic contract attached that states what the numbers mean.
In practice this usually means pre-modeled Parquet files that DuckDB queries directly. DuckDB reads columnar Parquet fast and needs no server process running in the background, giving an agent fast analytical compute over data that has already been checked and shaped, without the query ever reaching the production Postgres database. A single definition of a metric, written once into a semantic layer, does more for an agent than any amount of query tuning, because it closes off the ambiguity that otherwise lets two agents return two different ARR figures from the same underlying tables, each technically defensible and both useless together.
How MCP turns a governed DuckDB layer into something agents can discover and use without custom integration
A governed DuckDB layer only helps if agents can find it and use it without an engineer writing a bespoke integration for every agent framework that might want to query it. MCP closes that gap: it exposes tools and data sources through one consistent interface, so any compliant agent can discover and call them. Instead of custom glue code between a particular agent framework and a particular dataset, MCP gives both sides a shared contract: the model finds the tool, reads what it does, and calls it, with no hand-written integration required for each new pairing.
The January 2026 DuckDB ecosystem newsletter marks the point where this moved from theory to working example, covering agents querying data through MotherDuck's new MCP server. That was the moment DuckDB stopped being something only a backend service could reach and became something an agent could discover and query directly.
The protocol's usefulness for this pattern changed again with a July 2026 revision to the MCP spec, which removed the stateful handshake, the initialize and notifications exchange, and made the protocol stateless at the protocol layer. That sounds like a plumbing detail, but it has a direct consequence for anyone running DuckDB behind MCP: a server that used to require sticky sessions and a shared session store to track client state can now sit behind a plain round-robin load balancer. That turns a DuckDB-over-MCP deployment into ordinary horizontally scalable serverless infrastructure, rather than something that needs session affinity engineered around it.
MCP moves data and actions within reach of an agent. It does not check whether that data is correct. If an agent connects through MCP to a pile of un-certified tables, it will produce confident, wrong answers exactly as readily as an agent querying those same tables directly, because the protocol's job is transport and discovery, not validation. The semantic layer covered in the previous section has to exist before you wire up MCP. Build the governed dataset first, then expose it, in that order.
Reaching This Architecture Without Rebuilding the Stack
Teams running Supabase-backed applications are not short on analytical capability. Postgres can run any aggregation a team needs. Pointing agents or BI tools at the same Postgres instance serving the live application pulls in row-level security friction, connection pooler limits, and analytical queries competing for the OLTP compute the application needs for transactions, which creates a load problem. That cost compounds as agent query volume rises, because agents generate query volume at a pace and in a pattern human analysts never did.
pg_duckdb is the integration path the ecosystem has converged on. It is an openly licensed extension that runs the DuckDB engine inside PostgreSQL itself, intercepting analytical queries when a dedicated setting is turned on.force_execution` is turned on and routing them through DuckDB's columnar engine instead of Postgres's row-based one. The standard operational practice is to run it on a dedicated replica, keeping analytical load off the primary database.
Supabase backs this direction structurally through hires, product launches, and the extension ecosystem around it. Supabase brought on Joe Sciarrino, co-creator of Hydra, to build Supabase Warehouse, an open data warehouse architecture for developers, and the Hydra team, which maintains pg_duckdb, joined alongside him to focus on Postgres and analytics. Supabase also launched Analytics Buckets, now in public alpha: specialized storage built on Apache Iceberg and Amazon S3 that gives columnar storage for analytical workloads while keeping a Postgres-compatible interface on top.
The same pressure is visible at the infrastructure layer well beyond Supabase. AWS has stated the problem in terms specific to agents: "This challenge only grows as you increasingly embed AI agents into your applications, where it is impractical to predict and pre-replicate every dataset an agent might need." That is the same architectural argument made above for pre-modeled, governed datasets over on-demand production queries, and it arrives independently from a major cloud vendor.
For a team without a dedicated data engineer, the practical version of this stack is straightforward: Supabase Postgres running the transactional database, a nightly export of the relevant analytics tables to Parquet files, DuckDB running inside an API route to serve dashboard and agent queries, and governed metrics defined once on top of that. You need no separate warehouse to stand up, and no ETL pipeline to maintain beyond the nightly export itself.
A Well-Structured Agentic Analytics Workflow
Putting the pieces together produces a clear structure, one that separates two distinct planes of work. Large language models handle planning: they decide what to investigate and in what order. A deterministic layer of tools handles everything that follows: computation, statistics, security checks, and provenance tracking. DuckDB belongs entirely to that second plane. It never reasons about what to ask; it only answers what it is asked, against data whose shape and meaning are already fixed.
A reference open-source architecture built on this split works roughly as follows: an orchestration layer decomposes a question into smaller analytical tasks, runs them in parallel through an MCP tool layer sitting on top of DuckDB, checks every claim the agent produces against the actual rows that generated it, and publishes only the claims that survive that check. DuckDB itself runs locked to read-only throughout.
That verification step is what separates auditable output from output that is merely plausible. An answer with the SQL that produced it logged, and the specific rows behind each claim attached, can be rerun by anyone, tested against new data, and disputed if it looks wrong. An answer without that trail can only be believed or not, with no way to check which.
The input side of this system matters as much as the output side. Metrics calculated ahead of time and pushed out to dashboards, Slack channels, and reports, rather than computed on the fly whenever someone happens to ask, remove an entire category of error: the one where an agent builds its own metric logic from an ambiguous schema and gets it subtly wrong. The August 2026 newsletter also describes a related pattern: a separate DuckDB instance dedicated to AI workloads, populated through dlt extraction, where an agent's own analytical history lives in a database of its own rather than getting written back into the shared infrastructure other systems depend on.
Run the full chain together, governed datasets as deterministic input, DuckDB as deterministic compute, MCP as deterministic transport, logged SQL as deterministic output, and the result is an agent that can investigate a question and hand back an answer any engineer can check, rerun, and trust.


