> ## Documentation Index
> Fetch the complete documentation index at: https://docs.synehq.com/llms.txt
> Use this file to discover all available pages before exploring further.

# How It Works

> DuckDB federation, ATTACH, and orchestration

<Info>
  Tangent Lake uses DuckDB to attach multiple databases in a single session and execute federated SQL across them—securely and on demand.
</Info>

## DuckDB and ATTACH

DuckDB is an in‑process analytics database optimized for interactive workloads. A key feature used by Tangent Lake is **ATTACH**, which connects DuckDB to multiple sources (Postgres, MySQL, SQLite, DuckDB files, and more).

* Docs: <a href="https://duckdb.org/docs/stable/sql/statements/attach.html">ATTACH statement</a>
* Multi‑database: <a href="https://duckdb.org/2024/01/26/multi-database-support-in-duckdb.html">Multi‑database support</a>

## What this enables

* **Cross‑engine joins**: Join Postgres + MySQL + SQLite in one query
* **Live analytics**: Query without ETL; pull only the data needed
* **Schema discovery**: Fast introspection of tables, columns, relationships
* **On‑the‑fly movement**: Move data across engines with SQL when needed

## Orchestration

<AccordionGroup>
  <Accordion title="Session‑based attachments">
    Each Tangent is a session. Selected connections are attached for that session, enabling cross‑database access immediately.
  </Accordion>

  <Accordion title="Automatic query planning">
    DuckDB parses and optimizes your federated SQL, pushes down filters, and only fetches necessary data.
  </Accordion>

  <Accordion title="Extensions & formats">
    DuckDB’s pluggable extensions connect to Postgres, MySQL, SQLite, JSON/CSV, and cloud storage like S3/HTTPS.
  </Accordion>
</AccordionGroup>

## Example

```sql theme={"system"}
SELECT a.user_id, a.name, SUM(o.amount) AS total
FROM postgres_db.public.users a
JOIN mysql_db.sales.orders o ON a.id = o.user_id
GROUP BY a.user_id, a.name
ORDER BY total DESC;
```

<Note>
  You can explore attached schemas in Browse & Query and switch to the console to see generated SQL.
</Note>
