Query Plan Visualizer

PostgreSQL EXPLAIN (ANALYZE) or MySQL EXPLAIN JSON → plan tree, hot nodes and index suggestions.

PostgreSQL: EXPLAIN (ANALYZE, BUFFERS) … as text, or EXPLAIN (ANALYZE, FORMAT JSON). MySQL: EXPLAIN FORMAT=JSON …. psql headers, "+" line continuations and "(N rows)" footers are ignored.

Read in memory as UTF-8 text and not stored. Max 5 MiB.

When you run the tool, this file is uploaded to our server, processed and then deleted. The files the tool creates stay on our server for about 2 hours: download them to keep them, or save them to your Google Drive.

More options
×

Ratio between estimated and actual rows per loop.

Try an example: · ·

More about this tool

Part of Opsdeck Developer & cloud explorers

How it works

Paste PostgreSQL EXPLAIN / EXPLAIN ANALYZE output (text or FORMAT JSON) or MySQL EXPLAIN FORMAT=JSON. The plan is drawn as a node tree with cost, estimated vs actual rows, inclusive and exclusive time per node, and checked for the classic problems: row misestimates, sequential scans that discard most rows, sorts and hashes spilling to disk, nested loops over large inputs — each with a concrete fix such as a specific CREATE INDEX statement or work_mem setting.

  • PostgreSQL text plans are parsed by the "->" indentation; node headers give cost=startup..total rows width and (actual time=startup..total rows loops); detail lines (Filter, Rows Removed by Filter, Sort Method, Buckets/Batches, Buffers…) are mapped to the same keys as FORMAT JSON.
  • Actual time and rows are per-loop averages (PostgreSQL docs), so inclusive time = actual total time × loops; exclusive time = inclusive − children's inclusive time. Under Gather, time is divided by the number of participating processes.
  • Misestimate = max(estimated, actual)/min(…) rows per loop at or above the threshold (and ≥100 rows absolute difference).
  • Rules: Seq Scan with Filter removing ≥90% of ≥1000 rows; Index Scan still filtering; Sort Method external/Disk; Hash Batches > 1; Nested Loop with ≥1000 outer rows and a sequential inner side or ≥10k inner loops; lossy bitmaps; workers not launched; heap fetches in index-only scans.
  • Index candidates take equality-compared filter columns first, then the first range column (B-tree column-order rule); functions in filters call for expression indexes and leading-wildcard LIKE for pg_trgm.
  • MySQL: access_type ALL / index, filtered %, attached_condition columns, using_join_buffer, using_filesort and using_temporary_table (EXPLAIN FORMAT=JSON has estimates only, no timings).

Use this tool in an app

These free programs for your browser have this tool built in, next to everything else the task needs.

  • Opsdeck Developer & ops workbench

    One deck for CI failures, cron, traces, k8s events, API diffs, query plans and Terraform.

    Open Opsdeck

Related tools

How to use the Query Plan Visualizer

Paste PostgreSQL or MySQL EXPLAIN output and see where time goes, which estimates are wrong, and which index or setting would fix it.

What it is for

EXPLAIN ANALYZE tells you exactly why a query is slow, if you can read it. Times are per loop and include children, the interesting line is often buried three levels deep, and "Rows Removed by Filter: 4587127" doesn't shout as loudly as it should.

Paste PostgreSQL EXPLAIN / EXPLAIN (ANALYZE, BUFFERS) output (text or FORMAT JSON) or MySQL EXPLAIN FORMAT=JSON. The tool draws the plan as a tree with cost, estimated vs actual rows, and inclusive and exclusive time per node. It then checks for the classic problems:

  • Row misestimates
  • Sequential scans that throw away most rows
  • Sorts and hashes spilling to disk
  • Nested loops over large inputs

Each finding comes with a concrete fix, such as a CREATE INDEX statement or a work_mem value.

Index suggestions are candidates, not orders. Every index slows down writes and takes space, so check that the same columns appear in your other hot queries before you add one.

Worked example

The first built-in example is a PostgreSQL EXPLAIN (ANALYZE, BUFFERS) text plan: shipped orders since 2026-01-01, joined to customers, sorted by created_at DESC.

PostgreSQL plan with 5 nodes, 2.41 s execution: 4 findings, top: Sort spilled to disk at node #1; 1 index candidate.

Worked example
NodeInclusiveExclusiveFinding
#1 Sort2389.77 ms676.87 msexternal merge, 48,960 kB on disk
#2 Hash Join1712.90 ms209.28 ms—
#3 Seq Scan on orders1105.23 ms1105.23 msread 5,000,000 rows, removed 91.7%; planner expected 5,000 rows, got 412,873 (82.6×)
#4 Hash398.40 ms256.52 ms8 batches, so it spilled
#5 Seq Scan on customers141.88 ms141.88 ms—

The suggested index is CREATE INDEX CONCURRENTLY ON orders (status, created_at);: equality column first, then the range column. For the sort, the tool suggests SET LOCAL work_mem = '96MB' (an in-memory sort needs more than the on-disk size). For the hash, roughly 72 MB of work_mem or a higher hash_mem_multiplier.

Fix the misestimate first. With 82.6× more rows than planned, every memory decision above node #3 was sized for the wrong data. Running ANALYZE orders (or adding extended statistics if status and created_at are correlated) can change the whole plan.

The JSON example shows a different killer. A nested loop runs a sequential scan of products 20,000 times — 4,300 ms of the 4,381 ms total — because the planner expected 10 outer rows. The fix is CREATE INDEX CONCURRENTLY ON products (sku);.

How to read the result

  • Exclusive time — the column to sort by. It is the time a node spent itself, after subtracting its children. Inclusive time always looks worst at the root.
  • Rows ratio — estimated vs actual rows per loop. Large ratios mean bad statistics, and bad statistics mean bad plan choices.
  • Loops — PostgreSQL reports time and rows per loop. The tool multiplies by loops, which is why a 0.215 ms inner scan becomes 4.3 s.
  • Findings — severity, explanation and a specific suggestion per node.
  • Index candidates — ready-to-run statements with the reason behind them.

Tips and common mistakes

  • Use EXPLAIN (ANALYZE, BUFFERS). Plain EXPLAIN only has estimates, so no timings or misestimate checks are possible.
  • ANALYZE actually runs the query. Wrap data-changing statements in BEGIN; … ROLLBACK;.
  • Set work_mem per query or transaction (SET LOCAL), not globally. It applies per sort/hash node and per connection.
  • MySQL EXPLAIN FORMAT=JSON has costs but no timings. MySQL may also report the table alias (o) instead of the real name, so fix the table name in the suggested ALTER TABLE.
  • Run the plan twice. The first run may read from disk (Buffers: read=) and the second from cache.

FAQ

Can I paste the psql output as is?

Yes. Headers, the dashed line, + continuations and the "(N rows)" footer are handled.

Why does the root node show the most time?

Inclusive time contains all child nodes. Look at exclusive time to find the node doing the work.

What counts as a misestimate?

By default, estimated and actual rows per loop differing by a factor of 10 or more, with at least 100 rows absolute difference. You can change the factor.

Does the tool connect to my database?

No. It only parses the text you paste, so run EXPLAIN yourself and paste the output.

Guide last updated:

For scripts and AI agents

  • JSON API: POST https://queryplanvisualizer.usefulweb.site/api/v1/calculate (same calculation as this page)
  • Interface description: OpenAPI 3.1 · AI guide: llms.txt
  • MCP server (Streamable HTTP): https://queryplanvisualizer.usefulweb.site/mcp · tool name query_plan_visualizer
Example request
curl -s -X POST https://queryplanvisualizer.usefulweb.site/api/v1/calculate \
  -H 'content-type: application/json' \
  -d '{…see OpenAPI examples…}'
Feedback · ideas & bug reports welcome