> ## Documentation Index
> Fetch the complete documentation index at: https://ngquct-docs-fix-500-query-results.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# EXPLAIN Visualization

> View query execution plans as diagrams, trees, or raw output

**EXPLAIN** estimates. **EXPLAIN ANALYZE** runs the query and reports what actually happened. Choose between them from the dropdown beside **Explain** in the query editor toolbar, or use **Query > Explain Query** (`Cmd+Option+E`); engines with a single variant show a plain button instead.

The plan arrives as a result tab next to your query results, so going back to the data costs nothing, and pinning that tab keeps a plan while you try another query. Typing an `EXPLAIN` statement in the editor and running it opens the same viewer.

<Frame caption="MySQL EXPLAIN ANALYZE diagram">
  <img className="block dark:hidden" src="https://mintcdn.com/ngquct-docs-fix-500-query-results/HJY892UtvXUv1PFn/images/mysql-explain-analyze.png?fit=max&auto=format&n=HJY892UtvXUv1PFn&q=85&s=222063922550bc0c643a9992653be1a2" alt="MySQL EXPLAIN ANALYZE rendered as a plan diagram" width="3026" height="1720" data-path="images/mysql-explain-analyze.png" />

  <img className="hidden dark:block" src="https://mintcdn.com/ngquct-docs-fix-500-query-results/HJY892UtvXUv1PFn/images/mysql-explain-analyze-dark.png?fit=max&auto=format&n=HJY892UtvXUv1PFn&q=85&s=81cae56565af1feff8ac2c7cb0e016b5" alt="MySQL EXPLAIN ANALYZE rendered as a plan diagram" width="3028" height="1722" data-path="images/mysql-explain-analyze-dark.png" />
</Frame>

## Finding the expensive step

Every node carries a badge for its own share of the plan's total cost, taken after its children's cost is subtracted, so it marks where the work sits rather than where it accumulates.

| Badge                | Share of the plan's cost |
| -------------------- | ------------------------ |
| Green circle         | up to 5%                 |
| Yellow diamond       | over 5%                  |
| Orange triangle      | over 20%                 |
| Red warning triangle | over 50%                 |

Shape escalates alongside color, so the badge still reads with the system **Differentiate Without Color** setting on.

Then compare estimate against measurement. A node whose **Rows** estimate is orders of magnitude from its **Actual Rows** is why the planner chose that shape, so refresh the table's statistics before rewriting the query. On PostgreSQL a **Loops** value above 1 means the node ran once per row of its parent, which makes **Actual Time** the per-loop figure rather than the total.

<Frame caption="EXPLAIN diagram view">
  <img className="block dark:hidden" src="https://mintcdn.com/ngquct-docs-fix-500-query-results/hA72m8tSnRe3b-ew/images/explain-diagram.png?fit=max&auto=format&n=hA72m8tSnRe3b-ew&q=85&s=c496b22ec71234f5117c3da1ffdb6138" alt="EXPLAIN diagram view" width="3026" height="1720" data-path="images/explain-diagram.png" />

  <img className="hidden dark:block" src="https://mintcdn.com/ngquct-docs-fix-500-query-results/hA72m8tSnRe3b-ew/images/explain-diagram-dark.png?fit=max&auto=format&n=hA72m8tSnRe3b-ew&q=85&s=255818a03dde0ef34e611f8525792082" alt="EXPLAIN diagram view" width="3028" height="1722" data-path="images/explain-diagram-dark.png" />
</Frame>

## View modes

The segmented control above the results switches between three views. A plan the parser cannot read as a tree has no control at all and shows the raw output under a banner saying so.

### Diagram

Boxes joined by arrows, top to bottom. Zoom with a trackpad pinch, a two-finger double tap, or Cmd and scroll; the controls in the bottom-right corner zoom, reset to 100%, and fit the plan to the window. Right-click copies a step, and the export button saves the diagram as a PNG.

<Frame caption="EXPLAIN tree view">
  <img className="block dark:hidden" src="https://mintcdn.com/ngquct-docs-fix-500-query-results/hA72m8tSnRe3b-ew/images/explain-tree.png?fit=max&auto=format&n=hA72m8tSnRe3b-ew&q=85&s=7fee831e7a5e1d8e7950cf2a107c5f64" alt="EXPLAIN tree view" width="3026" height="1720" data-path="images/explain-tree.png" />

  <img className="hidden dark:block" src="https://mintcdn.com/ngquct-docs-fix-500-query-results/hA72m8tSnRe3b-ew/images/explain-tree-dark.png?fit=max&auto=format&n=hA72m8tSnRe3b-ew&q=85&s=16a4d1a53759e16cb6f476dc6f20b123" alt="EXPLAIN tree view" width="3028" height="1722" data-path="images/explain-tree-dark.png" />
</Frame>

### Tree

An expandable outline with **Operation**, **Cost**, **Rows**, and **Actual Time** columns. Drag a column edge to resize it and the width is remembered. Clicking a header sorts the steps under each parent without flattening the plan. Arrow keys move between steps, right-click copies one, and the divider resizes the detail panel.

### Raw

The original EXPLAIN output as text, with a copy button and a font size stepper. Planning and execution times, where the plan reports them, sit beside the view switcher in every mode.

## Node details

Selecting a node in either view fills the detail panel:

| Field                                       | What it holds                                                                            |
| ------------------------------------------- | ---------------------------------------------------------------------------------------- |
| **Table**                                   | The relation this step reads                                                             |
| **Cost**                                    | `startup..total`, or the total alone when that is all the plan carries                   |
| **Rows**, **Width**                         | Estimated row count and row width                                                        |
| **Actual Time**, **Actual Rows**, **Loops** | Present only on a measured plan                                                          |
| **Details**                                 | Everything else the driver reported: join type, index name, filter conditions, sort keys |

Properties the driver reported as false or zero are left out of **Details**.

## Database support

| Database                              | Variants                                    | Diagram and tree                                                                                                |
| ------------------------------------- | ------------------------------------------- | --------------------------------------------------------------------------------------------------------------- |
| PostgreSQL, PGlite, Redshift          | EXPLAIN, EXPLAIN ANALYZE                    | From `EXPLAIN (FORMAT JSON)`                                                                                    |
| CockroachDB                           | EXPLAIN, EXPLAIN ANALYZE                    | From the text plan                                                                                              |
| MySQL                                 | EXPLAIN, EXPLAIN (JSON)                     | From JSON, and from a typed `EXPLAIN FORMAT=TREE` or `EXPLAIN ANALYZE`. Plain EXPLAIN stays in the results grid |
| MariaDB                               | EXPLAIN, EXPLAIN (JSON)                     | From JSON, including a typed `ANALYZE FORMAT=JSON`. Plain EXPLAIN stays in the results grid                     |
| SQLite, Cloudflare D1, libSQL / Turso | Query Plan                                  | From `EXPLAIN QUERY PLAN`                                                                                       |
| ClickHouse                            | Plan, Pipeline, AST, Syntax, Estimate       | From the indented text                                                                                          |
| DuckDB                                | Explain                                     | From the indented text                                                                                          |
| Snowflake                             | Explain (Text)                              | Raw text only                                                                                                   |
| Trino                                 | Logical, Distributed, IO, Validate, Analyze | Raw text only                                                                                                   |
| SurrealDB                             | Explain, Explain Full                       | Raw text only                                                                                                   |
| BigQuery                              | Dry Run (Cost)                              | A dry run cost estimate, no plan                                                                                |
| MongoDB                               | Explain                                     | The `explain` runCommand with execution stats                                                                   |
| Redis                                 | Explain                                     | `DEBUG OBJECT` for the command's key                                                                            |

<Warning>
  `EXPLAIN` does not run the query. `EXPLAIN ANALYZE` does, so on a production server it costs whatever the query costs. Safe Mode asks before an EXPLAIN too, whichever way you started it, and the Stop button cancels one that is taking too long.
</Warning>
