Trino vs DuckDB vs a federated query engine: when to use which
You like DuckDB and wonder whether it can be the shared SQL layer for your team, apps and agents. This guide compares DuckDB, Trino and a federated query engine on where each runs, who connects, writes, access control and CDC. The DuckDB 2.0 server mode is checked against the official docs.
On this page
DuckDB is an embedded engine for one analyst or one process. A federated query engine such as Otterstax is a shared server over live databases. It serves applications, dashboards and AI agents. Trino is a cluster for analytics over a data lake with Iceberg or Delta Lake tables. A Trino vs DuckDB comparison should include the federated engine as a third option.
| DuckDB | Federated query engine (Otterstax) | Trino | |
|---|---|---|---|
| Where it runs | Inside your process; 2.0 adds an HTTP server for other DuckDB instances | One process (open source); Kubernetes cluster (Enterprise) | One coordinator, zero or more workers |
| Who connects | The host program; other DuckDB instances over Quack | Any MariaDB / MySQL or PostgreSQL driver, Arrow Flight SQL, ADBC, MCP for agents | Trino CLI, JDBC, Python / Go / JavaScript / C# clients |
| Writes to sources | Yes, through the postgres and mysql extensions |
Reads; writes to its own tables | Yes, with limits per connector |
| Cluster | No; one machine | Kubernetes cluster with auto-failover (Enterprise) | Yes, by design |
| Access control | One token per server; authorization “permissive” by default | One permission model for people and agents; LDAP / SSO / Vault (Enterprise) | LDAP, OAuth 2.0, Kerberos, JWT; file-based, OPA or Ranger rules |
| CDC | No | CDC with guarantees (Enterprise) | No |
How DuckDB reads PostgreSQL and MariaDB through ATTACH
DuckDB attaches an external database with one statement. The postgres and mysql extensions autoload on first use; the latter also serves MariaDB. Filter pushdown is on by default in both. With READ_ONLY, DuckDB refuses to modify the source. Without it, INSERT, UPDATE and DELETE change the source database directly.
ATTACH 'dbname=billing user=reader host=billing-db' AS pg (TYPE postgres, READ_ONLY);
SELECT count(*) FROM pg.public.invoices WHERE paid;The full MariaDB + PostgreSQL join, with secrets instead of passwords, is in how to join tables from different databases.
This setup is hard to beat for one person on one laptop, and it runs into problems when a dashboard or a service needs the same view.
DuckDB as a server: concurrency, users, writes
DuckDB “does not run as a separate process but is completely embedded within a host process”. In that mode a database opens in one of two ways. In read-write mode, one process reads and writes the database. In read-only mode, several processes read and none writes. Inside the writing process, several threads can write. A conflict on the same rows raises a transaction error.
DuckDB 2.0.0, released 2026-10-21, changes part of this. The quack extension “turns a DuckDB instance into a server that other DuckDB instances (clients) can connect to over HTTP”. You start it with CALL quack_serve(...); clients use ATTACH 'quack:...' or CONNECT. By default the server listens on localhost only.
Read the Quack security page before you call it a shared query layer:
- The documented clients are DuckDB instances with the extension. There is no PostgreSQL or MariaDB wire protocol. An ORM or a BI tool cannot connect with its usual driver.
- Authentication is one token per server. “Authorization is permissive”: the default hook passes every query through. You build users, roles and per-table grants yourself.
- A server “exposes the full SQL surface of the underlying DuckDB instance”. That includes “read and write access to every table the server’s session can see”.
- It is still one DuckDB instance on one machine.
- There is no CDC.
For a hosted option, MotherDuck describes itself as “the serverless cloud data warehouse built on DuckDB”.
Quack fits DuckDB clients that trust each other. For the drivers, tools and agents you already run, use a federated query engine.
DuckDB vs PostgreSQL: analytics next to a transactional database
DuckDB “is designed to support analytical query workloads”. It does not replace a transactional database. Keep orders and accounts in PostgreSQL or MariaDB and read them from DuckDB when you need a fast local scan. A federated query engine makes the same split: transactions go to the row store, analytics to a column store or the engine. See analytics without ETL.
DuckDB vs ClickHouse: embedded engine or analytics server
ClickHouse is “a high-performance, column-oriented SQL database management system (DBMS) for online analytical processing (OLAP)”. It runs as a server, stores its own data and serves many users. DuckDB is embedded analytics inside one program, and the two can run side by side. Pick ClickHouse when events arrive all day and many people query them. When one process needs fast SQL over files or a local copy, DuckDB is the better fit. ClickHouse can also be a source for a federated query engine: Otterstax joins ClickHouse events with MariaDB orders in one statement.
Apache Spark is “a unified analytics engine for large-scale data processing” and runs over cluster managers. If the data fits one machine, DuckDB is the simpler tool.
DuckDB, Trino and Otterstax at a glance
| Question | DuckDB | Trino | Otterstax |
|---|---|---|---|
| Built for | Analytics inside one program | “Data warehousing and analytics”; “not a replacement for databases like MySQL, PostgreSQL or Oracle” | Apps, dashboards and agents over MariaDB, PostgreSQL, ClickHouse, S3 and Kafka |
| App connects with | DuckDB client library | Trino client or JDBC | Existing MariaDB / MySQL or PostgreSQL driver (ports 8816 / 8817) |
| Cross-database JOIN overhead | Depends on how much data the laptop pulls | Depends on cluster size | +10–20% first run, +5–10% repeat, measured in customer production against JOINs in app code and ETL |
Otterstax is built for the case DuckDB leaves open, where many clients connect, each with a driver it already has. People and AI agents share one permission model through the MCP gateway. One customer case: an online marketplace monitored ad A/B tests on data that an ETL script refreshed every 3 hours. With Otterstax the marketing team queries live data, and the ETL script is gone.
When to use DuckDB
Use DuckDB when:
- One person needs the answer. An analyst joins a PostgreSQL table with a parquet export and ships a chart.
- The data fits one machine. DuckDB’s goal is “high-speed data transfer to and from the database” inside the process. A federation layer adds a network hop on every query.
- The query runs inside your application. For example, a Python service that scores a local batch, a CLI tool or a notebook.
- The sources are files. Parquet and CSV on S3 or disk are DuckDB’s home ground.
Move to a federated query engine when the second client arrives, a service must write, or permissions differ per user. Move to Trino when the data lives in a lake and scans are measured in terabytes.
FAQ
Can DuckDB join PostgreSQL and MySQL or MariaDB tables?
Yes. Load the postgres and mysql extensions, ATTACH both databases, and write a normal JOIN across the two aliases. The join runs inside your process, so teammates, dashboards and services cannot share it. For that, put a federated query engine in front of both databases.
Is DuckDB faster than Trino?
For one user on one machine, often yes, because there is no cluster, coordinator or network between workers. Trino exists for the case DuckDB cannot cover, analytics over terabytes in a lake with many users at once. Benchmark them on your own queries and data size.
Can several apps share one DuckDB?
Only within limits. Several processes can read one database file in read-only mode; only one process can write. DuckDB 2.0 adds the Quack server, but its clients are other DuckDB instances. Access is one token, and authorization is permissive by default. Apps that need their own driver and their own permissions need a federated query engine.
Next step
The open-source Otterstax quickstart runs locally in about five minutes. To map it onto production databases, book a 30-minute pilot call. For the feature table against Trino, see Otterstax vs Trino.
Sources
- DuckDB docs: Handling Concurrency — checked 30.10.2026
- DuckDB docs: Quack overview — checked 30.10.2026
- DuckDB docs: Quack security — checked 30.10.2026
- DuckDB blog: Announcing DuckDB 2.0.0 — checked 30.10.2026
- DuckDB docs: PostgreSQL extension — checked 30.10.2026
- DuckDB docs: MySQL extension — checked 30.10.2026
- DuckDB: Why DuckDB — checked 30.10.2026
- MotherDuck docs: Getting started — checked 30.10.2026
- Trino docs: Concepts — checked 30.10.2026
- Trino docs: Use cases — checked 30.10.2026
- Trino docs: Clients — checked 30.10.2026
- Trino docs: Security — checked 30.10.2026
- Trino docs: PostgreSQL connector — checked 30.10.2026
- ClickHouse docs: Introduction — checked 30.10.2026
- Apache Spark documentation — checked 30.10.2026
- Otterstax: /how-it-works, /ai-agents, /use-cases/analytics-without-etl, /compare/trino, GitHub README and quickstart
More guides
-
What is a federated query engine?
A federated query engine runs one SQL query across several databases without copying data. How it works, how it differs from ETL, and when you need it.
-
Database migration strategies: zero downtime, table by table
Big bang, replica and cutover, dual writes, or table by table through a federated query engine: downtime, rollback and app changes compared, with code.
-
Zero-ETL analytics: when to replace ETL with federated queries
What zero-ETL means, what stays on ETL, what moves to queries on live databases, and how to switch one dashboard at a time without hurting the app.
See Otterstax on your own data sources
In a 30-minute call we'll map your stack and show a working query across your data sources.