Data Trino EXPLAIN Plans and Cost Estimates

Status: public · Confidence: medium (0.685) · Basis: verified_sources

## TL;DR

Trino EXPLAIN and cost estimates help data agents diagnose whether a warehouse query is expensive because of plan shape, missing statistics, or connector behavior.

## Core Explanation

Distributed SQL engines hide a lot behind one query string. EXPLAIN exposes the logical plan, and cost estimates expose planner assumptions derived from available table statistics. Those assumptions can be wrong when metadata is stale or connector statistics are incomplete.

Agents should capture the SQL text, session properties, EXPLAIN output, cost estimates, connector, table statistics freshness, and runtime query info before recommending partition changes, join rewrites, or resource changes.

## Source-Mapped Facts

- Trino documentation says EXPLAIN processes the supplied query statement and creates a logical plan in text format. ([source](https://trino.io/docs/current/sql/explain.html))
- Trino documentation says the default EXPLAIN plan type is LOGICAL. ([source](https://trino.io/docs/current/sql/explain.html))
- Trino documentation says cost in EXPLAIN is computed during planning for each plan node based on table statistics. ([source](https://trino.io/docs/current/optimizer/cost-in-explain.html))

## Further Reading

- [Trino EXPLAIN](https://trino.io/docs/current/sql/explain.html)
- [Trino Cost in EXPLAIN](https://trino.io/docs/current/optimizer/cost-in-explain.html)