# How the federated query engine works: one endpoint, no data copies

Otterstax is an open-source federated query engine: your apps and AI agents connect to it like a regular MariaDB or PostgreSQL database, and it runs each query where the data lives — across MariaDB, PostgreSQL, ClickHouse, S3, Kafka and Spark — without copying data.

Up and running without touching your application code

## 1. Connect your sources.

Register MariaDB, PostgreSQL, ClickHouse, S3, Kafka or Spark in the Otterstax catalog. Otterstax doesn’t copy their data.

- mariadb_prod: connected
- pg_billing: connected
- clickhouse_events: connected
- s3://lake: 0 bytes copied

## 2. Point your app at Otterstax.

Use the MariaDB / MySQL or PostgreSQL driver, ORM or BI tool you already have. Analytics tools can use Arrow Flight SQL or ADBC, and AI agents can use MCP.

```diff
# .env
- DATABASE_URL=mysql://app@mariadb-prod:3306
+ DATABASE_URL=mysql://app@otterstax:8816
```

## 3. Query across everything.

JOIN tables from different data sources, write with INSERT, UPDATE and DELETE, and call ML models as SQL functions (Enterprise).

```sql
SELECT u.country, SUM(p.amount)
FROM mariadb_prod.app.users u
JOIN clickhouse_events.analytics.payments p
  ON p.user_id = u.id GROUP BY u.country;
```

Only the data you ask for moves over the network. Your data sources stay where they are.

## Three parts of one system

Otterstax is one process — or one cluster in Enterprise — with three layers.

### Federated Query Engine

The catalog knows every connected source, the planner splits each query, and pushdown sends the heavy work to the sources. Queries run where the data lives.

### Compute Proxy Layer

The endpoint your apps and AI agents connect to: MariaDB / MySQL and PostgreSQL wire protocols, Arrow Flight SQL, ADBC and MCP, with connection pooling, caching and routing.

### ML SQL (Enterprise)

ONNX models run as SQL functions, next to the data, on CPU or GPU nodes.

[What is a federated query engine? →](https://otterstax.com/guides/what-is-a-federated-query-engine) · [Latest release →](https://github.com/otterstax/otterstax/releases/latest) · [Changelog →](https://github.com/otterstax/otterstax/releases)

## Architecture

Otterstax architecture: apps, BI tools, analytics and AI agents connect over the MariaDB / MySQL and PostgreSQL wire protocols, Arrow Flight SQL, ADBC and MCP, and query MariaDB, PostgreSQL, ClickHouse, S3 and Kafka. One write can go to MariaDB and ClickHouse at once..

- Backend and Agentic clients: Your app (MariaDB driver), BI tool (PostgreSQL), Analytics / ML (Arrow Flight SQL, ADBC), AI agent (MCP)

- Otterstax: mysql, postgres, flight-sql, adbc, mcp · catalog • planner • pushdown · one INSERT → MariaDB + ClickHouse

- Your data sources: MariaDB, PostgreSQL, ClickHouse, S3, Kafka

Queries run where the data lives. Otterstax doesn’t copy it.

## Change data capture, built in

Otterstax keeps sources in sync without a separate CDC stack. Open source has CDC without delivery guarantees; CDC with guarantees in a cluster is Enterprise.

### Native connections.

Changes are read over the database’s own logical replication. No Kafka Connect needed.

### Filtering and transforms in flight.

Filter rows and transform them with SQL while they move, before they reach the target.

### Dual writes for gradual migration.

During a migration, writes go to the old and the new database at once, so each table switches over when it is ready.

[Read: gradual database migration →](https://otterstax.com/use-cases/database-migration)

## Before / After

**Before:**

- 3 database drivers in every service
- nightly ETL jobs
- sync scripts between data sources
- analytics on data that is hours old
- migration = rewrite every service

**After • with Otterstax:**

- 1 connection string
- queries run in place
- writes go to the right database
- fresh data in seconds
- migrate table by table

## Migration demo

Migration demo: the orders table moves from PostgreSQL to MariaDB while the app keeps the same Otterstax connection string.

1. Query
2. Move orders to MariaDB
3. Same query again

DATABASE_URL: `mysql://app@otterstax:8816`

```sql
SELECT u.country, COUNT(o.id) AS orders, SUM(o.total) AS revenue
FROM orders o
JOIN users u ON u.id = o.user_id
GROUP BY u.country
ORDER BY revenue DESC;
```

| country | orders | revenue |
| --- | --- | --- |
| US | 1,284 | 184,920.40 |
| DE | 702 | 96,311.75 |
| GB | 518 | 71,048.10 |
| FR | 391 | 52,776.00 |
| NL | 233 | 31,502.65 |

catalog updated: orders → mariadb_prod. application config: no changes.

The query and the connection string stayed the same. Your app never noticed.

[Read: gradual database migration →](https://otterstax.com/use-cases/database-migration)

## Speaks your stack: MariaDB / MySQL and PostgreSQL wire protocols

- **Wire protocols:** MariaDB / MySQL, PostgreSQL, Arrow Flight SQL, ADBC, MCP (AI agents), Spark Connect.
- **Sources:** MariaDB / MySQL, PostgreSQL, ClickHouse, S3-compatible storage (AWS S3, MinIO), Kafka, Redis, ScyllaDB. Spark integration via PySpark, Spark Connect and Spark Java.
- **Roadmap:** BigQuery, MongoDB, MS SQL Server, vector databases, Iceberg / Delta.
- **Scale:** Open source: one process. Enterprise: a Kubernetes cluster with auto-failover, spill to disk and a cost-based adaptive optimizer.
- **Schemaless:** Source schemas are discovered automatically, and you can query data without a fixed schema: JSON, documents, Kafka events.
- **Formats:** Parquet, CSV, JSON / NDJSON, Arrow, ORC.
- **Read and write:** cross-database JOINs, INSERT / UPDATE / DELETE, `CREATE EXTERNAL TABLE`, `COPY ... TO`.
- **Extend:** User-defined functions and custom types — plug your own logic into the engine.
- **Built on:** the Otterbrix query engine (C++), Apache 2.0.

revenue_by_country.sql:

```sql
-- one query, two databases
SELECT u.country, SUM(e.amount) AS revenue
FROM mariadb_prod.app.users u
JOIN clickhouse_events.analytics.payments e ON e.user_id = u.id
WHERE e.ts > now() - INTERVAL 1 HOUR
GROUP BY u.country;
```

`$ psql -h localhost -p 8817 -U demo demo`

[Run it locally in 5 minutes → Quickstart](https://github.com/otterstax/otterstax/tree/main/examples/quick_start)

## Proof for engineers

Measured in customer production on complex cross-database queries over MariaDB or PostgreSQL with Kafka and S3. Baseline: the customer's previous setup, with JOINs in application code and through ETL.

- **Cross-database JOIN, first run:** +10–20% — overhead vs the previous setup, worst case
- **Same query, repeat runs:** +5–10% — plan and metadata cache, data cache, warm connections
- **DWH queries vs Trino:** 5–15 p.p. — lower overhead than Trino on the same clusters

Trade-offs: every query adds one network hop, and a query across several data sources waits for the slowest one. The planner pushes heavy work down to the sources to compensate.

[Benchmark harness on GitHub →](https://github.com/otterstax/otterstax/tree/main/benchmark)

[Otterstax vs Trino — full comparison](https://otterstax.com/compare/trino)

## Frequently asked questions

### Do I need to change my application code?

No. Your app connects with its existing MariaDB / MySQL or PostgreSQL driver or ORM. You only change the connection string. Otterstax translates part of the SQL for the target database and passes database-specific SQL through as is.

### Does Otterstax copy my data?

No. Otterstax doesn't store your data: queries run where the data lives, and only the rows a query needs pass through. You can turn on caching for heavy analytical queries. During a migration, data moves straight from the old database to the new one, and Otterstax keeps them in sync with CDC until you switch over.

### What is the latency overhead?

On complex cross-database JOINs, 10–20% on the first run and 5–10% on repeat runs, compared with JOINs in application code or through ETL. Repeat runs are cheaper thanks to plan and metadata caching, data caching and warm connections. Measured in customer production.

### What SQL is not supported?

Otterstax translates part of the SQL for each target database and passes database-specific SQL through as is.

### Where does Otterstax get slow?

When a JOIN brings hundreds of millions of intermediate rows into Otterstax, and when a source database is already overloaded. Every query also adds one network hop, and a query across several data sources waits for the slowest one. The planner pushes heavy work down to the sources to compensate.

### Where can I deploy it?

Open source runs as a single process and starts with a docker-compose quickstart. Enterprise runs as a cluster in Kubernetes. Installation and updates work without internet access (air-gapped).

### Does Otterstax support ADBC?

Yes, in open source, alongside Arrow Flight SQL and the MariaDB / MySQL and PostgreSQL wire protocols.

### Does Otterstax work with Spark?

Yes. Spark jobs can read through Otterstax via PySpark, Spark Connect and Spark Java.

## 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.

[Talk about a pilot](https://otterstax.com/demo) · [Start with open source](https://github.com/otterstax/otterstax/tree/main/examples/quick_start)

---

Source: https://otterstax.com/how-it-works · Otterstax · info@otterstax.com
