# How Trino Works

Trino uses an architecture similar to a classic massively parallel processing (MPP) database management system.

![image](/assets/348797.ff6efa08d4c921004dd71c4d8f08aa117c9c165f7e9666b6598dc86f4b83fbc7.0053d791.png)

## Architecture

Trino has one coordinator node working in sync with multiple worker nodes.
When you submit a SQL query, the coordinator parses it, builds a distributed query plan, and schedules it across the worker nodes.

Trino supports standard ANSI SQL semantics, including:

- Complex queries and aggregations
- Joins (inner, left/right outer joins)
- Sub-queries and window functions
- Distinct counts and approximate percentiles


## Query Execution

After a query is compiled, Trino processes the request into multiple stages across the worker nodes.
All processing is in-memory and pipelined across the network between stages to avoid unnecessary I/O overhead.
This enables interactive query performance.

![image](/assets/344694.e2538ca868095704107dbfe8ade79034b63359cf9aad43dd256fa90d05360bb2.0053d791.png)

### Memory Limitations

Trino has a maximum memory limit for each query. If a query requires more memory than the limit, the query will fail.
To work within these limits:

- Use appropriate filtering with `TD_TIME_RANGE` to reduce data volume
- Avoid operations that require single-node processing (e.g., `ORDER BY`, `count(distinct)`)
- Use `CREATE TABLE AS SELECT` for large result sets instead of returning results directly


For more information on handling memory errors, see [Trino Performance Tuning](/ja/products/customer-data-platform/data-workbench/queries/trino/performance_tuning).