SQL EXPLAIN plan viewer
Paste your PostgreSQL EXPLAIN output and see the query plan as a readable colour-coded tree with cost estimates and node annotations.
About this tool
PostgreSQL's EXPLAIN command reveals exactly how the query planner intends to execute your SQL. The output is a tree of plan nodes — each describing an operation like a sequential scan, index scan, hash join, or sort — along with estimated cost, row count, and row width. Reading this tree by eye is error-prone: multi-level indentation, jargon-heavy node names, and raw cost numbers make it hard to spot what is actually happening. This tool parses the EXPLAIN text output and renders it as a colour-coded, collapsible plan tree. Each node is labelled by type and annotated with its startup and total cost, estimated row count, and output width. Supplementary lines such as filter predicates, index conditions, join conditions, and sort keys are collapsed under a "Show details" toggle to keep the tree readable. Supported node types include sequential scans, index scans (forward, backward, index-only), bitmap scans, nested loop, hash join, merge join, hash, sort, aggregate, group aggregate, hash aggregate, limit, append, CTE scan, function scan, and more. Paste any EXPLAIN output in the default PostgreSQL text format and the tree appears instantly — no signup, no server round-trip.
- 1
Run EXPLAIN <your SQL query> in psql or your PostgreSQL client.
- 2
Copy the full output, including every indented line.
- 3
Paste it into the input field and click Visualize plan.
- 4
Each node shows its type, estimated cost range, row estimate, and output width.
- 5
Click 'Show details' on any node to reveal predicates, join conditions, and sort keys.
Understand what the planner is doing before optimizing a slow query.
Confirm that an index is being used rather than a sequential scan.
Share a query plan with a colleague in a readable format.
Learn PostgreSQL query planning by seeing how different queries produce different plan shapes.
Sequential scan with filter
Seq Scan on users (cost=0.00..1.05 rows=5 width=78)
Filter: (active = true)Tree: Seq Scan on users — cost 0.00..1.05, est. 5 rowsHash join of two tables
Hash Join (cost=1.09..2.27 rows=5 width=16)
Hash Cond: (orders.user_id = users.id)
-> Seq Scan on orders (cost=0.00..1.18 rows=18 width=12)
-> Hash (cost=1.05..1.05 rows=5 width=8)
-> Seq Scan on users (cost=0.00..1.05 rows=5 width=8)Tree: Hash Join → Seq Scan on orders / Hash → Seq Scan on usersNo plan nodes found
Cause: The pasted text does not contain a PostgreSQL EXPLAIN output in text format. You may have pasted JSON-format EXPLAIN, a MySQL EXPLAIN table, or unrelated query output.
Fix: Run EXPLAIN without FORMAT JSON or FORMAT XML. The default text format starts with a line like 'Seq Scan on … (cost=0.00..1.05 rows=5 width=78)' or 'Hash Join (cost=…)'.
Plan tree looks incomplete or collapsed into one node
Cause: Child nodes start with '-> ' preceded by spaces. If the indentation was lost (e.g. copied from a web UI that stripped whitespace) the parser cannot reconstruct the hierarchy.
Fix: Copy the EXPLAIN output directly from psql, DataGrip, pgAdmin's Text tab, or a terminal. Avoid pasting from sources that strip leading spaces.
These answers explain common sql explain viewer tasks, expected input formats, and edge cases so both visitors and search engines can understand what this tool does.
What is EXPLAIN in PostgreSQL?
EXPLAIN shows the query plan chosen by PostgreSQL's planner without actually running the query. It returns a tree of plan nodes, each describing one operation (scan, join, sort, aggregate) with estimated cost and row count.
What do the cost numbers mean?
Each node shows startup..total cost. Startup cost is the planner's estimate of how much work is needed before the first row can be returned (relevant for nested loops). Total cost is the estimate to return all rows. Units are arbitrary — they're useful for comparing nodes relative to each other, not as wall-clock times.
What does 'rows' mean?
The rows figure is the planner's estimate of how many rows the node will emit. It's based on table statistics (pg_statistic). If statistics are stale, the estimate can be far off — which often causes poor plan choices.
What is 'width'?
Width is the estimated average size, in bytes, of a single output row from that node. It affects memory usage estimates for sorts, hashes, and aggregates.
What is the difference between EXPLAIN and EXPLAIN ANALYZE?
EXPLAIN shows the plan without running the query. EXPLAIN ANALYZE actually runs it and shows actual execution times and row counts alongside the estimates. Use the SQL EXPLAIN ANALYZE Analyzer tool on this site for that.