Explain Plan
See how the database runs a statement: which indexes it uses, where it scans a whole table and which step takes the most time.
Run Explain
- Click Explain in the editor toolbar or press
Cmd/Ctrl+Shift+E. The database returns its plan with estimates and does not run the statement - Click the arrow next to the button and pick Explain analyze. The database runs the statement and returns the plan with the actual row counts and timings
The toolbar button works when the query file, or your selection, has one statement. When the file has more statements, right-click the run button next to the statement and pick Explain or Explain analyze there.
UPDATE or a DELETE changes the rows, so it goes through the transaction mode like any other write, and a data source in read-only mode rejects it.Read the plan
The plan opens in the Results tab as a tree. Each row is one step of the plan, with the steps it depends on nested below it.
- Operation with its table, index and condition
- Est. rows and Est. cost from the planner
- Actual rows, Loops and Self ms after Explain analyze. Self ms is the time of the step without the steps below it
- Share shows how much of the cost or the time each step takes. The most expensive step is highlighted
- The
full scanbadge marks a step that reads a whole table - The
rows 10x offbadge marks a step where the actual row count is at least ten times away from the estimate - The planning and execution time are below the tree
Switch between Tree and Raw to see the plan the way the database returned it, and use Copy plan to copy it.
Plans by database
| Database | Explain | Explain analyze | Plan is shown as |
|---|---|---|---|
| PostgreSQL | ✓ | ✓ | Tree |
| MySQL / MariaDB | ✓ | ✓ | Result grid or text |
| SQLite | ✓ | n/a | Tree without estimates |
| DuckDB | ✓ | ✓ | Text |
Ask an agent about the plan
An AI agent in the chat can read the plan that is shown in the Results tab. It gets the full plan and a summary with the most expensive step, the full scans and the steps with wrong row estimates, so you can ask it why the query is slow.
