> For the complete documentation index, see [llms.txt](https://docs.pinot.apache.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.pinot.apache.org/build-with-pinot/querying-and-sql/query-execution-controls/explain-plan-multi-stage.md).

# Explain Plan (Multi-Stage)

Multi-stage explain plan guidance for Pinot SQL.

{% hint style="info" %}
For the complete, up-to-date explain plan reference (including segment plans, logical plans, and workers plans), see [Explain Plan](/build-with-pinot/querying-and-sql/multi-stage-query/explain-plan-1.md) in the multi-stage query section.
{% endhint %}

Multi-stage explain plans are useful when a query uses features such as joins, subqueries, or distributed reshaping that do not exist in the single-stage path.

## What to look for

* logical plan shape
* exchange and distribution boundaries
* join and aggregation placement
* implementation details when you need to see the physical operator chain

If you only need to understand a simple filter or aggregation query, the single-stage explain plan page is usually enough.

## Useful patterns

When debugging multi-stage execution, start by:

1. running `EXPLAIN PLAN FOR`
2. checking whether the plan is logical or implementation-oriented
3. comparing the result with the query options you set

## What this page covered

This page covered what the multi-stage explain plan is useful for and how to approach it when debugging advanced SQL.

## Next step

If you are still deciding between engines, read [SSE vs MSE](/build-with-pinot/querying-and-sql/sse-vs-mse.md) in the broader query section.

## Related pages

* [Explain plan](/build-with-pinot/querying-and-sql/query-execution-controls/explain-plan.md)
* [Querying Pinot](/build-with-pinot/querying-and-sql/querying-pinot.md)
* [SQL syntax](/build-with-pinot/querying-and-sql/sql-syntax.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.pinot.apache.org/build-with-pinot/querying-and-sql/query-execution-controls/explain-plan-multi-stage.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
