> 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.md).

# Explain Plan (Single-Stage)

Use `EXPLAIN PLAN FOR` when you want to understand how Pinot will execute a query before or while tuning it.

## What it tells you

Explain plan output helps you see:

* which operators Pinot will run
* whether an index is being used
* where filters, projections, and aggregations happen
* how a query is shaped in single-stage or multi-stage execution

```sql
EXPLAIN PLAN FOR
SELECT city, COUNT(*)
FROM stores
GROUP BY city;
```

## Single-stage and multi-stage

Single-stage explain plans are best for understanding the operator flow behind straightforward queries.

Multi-stage explain plans are better when you need to inspect joins, subqueries, or the distributed execution shape.

## How to use it

Start with explain plan when a query is:

* slower than expected
* not using the index you expected
* returning a shape that is hard to reason about

Then pair the plan with query options or index guidance if you need a fix.

## What this page covered

This page covered what explain plan shows, when to use it, and how the single-stage and multi-stage engines differ.

## Next step

If you need a deeper execution-shape discussion, read [SQL syntax](/build-with-pinot/querying-and-sql/sql-syntax.md) and then revisit query options or quotas if the issue is runtime control rather than syntax.

## Related pages

* [Query options](/build-with-pinot/querying-and-sql/query-execution-controls/query-options.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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
