Postgres EXPLAIN Plan Visualizer

Turn EXPLAIN ANALYZE output into a readable tree and flame chart, find the nodes that take the time and get concrete index and work_mem hints.

Draait in je browser. Je bestanden verlaten je apparaat nooit. Zie hoe je dit controleert

…

Zo doe je het

  1. 1
    Run EXPLAIN

    Copy the EXPLAIN prefix, run it before your query and copy the full output.

  2. 2
    Paste the plan

    Paste it into Plan text; name the plan so you can compare later.

  3. 3
    Read the summary

    Check execution time, node count and the list of slowest nodes.

  4. 4
    Explore the tree

    Use the Tree tab, collapse branches and click nodes for their details.

  5. 5
    Check the flame view

    Look for wide bars low in the Flame tab.

  6. 6
    Apply hints

    Open Hints, copy the suggested SQL and test it on a copy of your data.

  7. 7
    Export

    Download report saves an HTML summary with hints and the node table.

Over deze tool

When a PostgreSQL query is slow, EXPLAIN ANALYZE tells you why, but its output is a wall of indented text with times that include child nodes and repeat per loop. This visualizer parses plain text (as psql or pgAdmin prints it) and the FORMAT JSON variant, rebuilds the plan tree and computes self time for every node: the node's total time multiplied by its loops, minus the time of its children. Nodes are coloured by their share of the runtime, so the expensive step jumps out. A flame view shows the same plan as nested bars, a sortable table lists every node, and a hints tab looks for the patterns database engineers check first: sequential scans that throw away most rows, sorts and hashes that spill to disk, nested loops that rescan a table thousands of times, and row estimates that are off by ten times or more. Hints come with ready-to-test SQL.

Who this is for

Backend developers chasing a slow endpoint, data analysts tuning reports, DBAs reviewing a query before release, and students learning how the planner works.

Getting the plan

Run EXPLAIN (ANALYZE, BUFFERS) followed by your query in psql, pgAdmin, DBeaver or any client, and paste the output. Borders, quotes and the row-count footer that clients add are removed automatically. FORMAT JSON output works too. Because ANALYZE really runs the statement, wrap INSERT, UPDATE and DELETE in BEGIN and ROLLBACK. Several plans can be saved under names, which is handy to compare before and after adding an index.

Tree view

Each node shows its type, table and index, self time and share, actual rows and loops, the planner's estimate and the cost. A coloured left border marks the hot nodes; badges flag estimate errors and hints. Collapse branches to focus. Click a node for every detail line such as Filter, Index Cond, Hash Cond, Sort Key, Sort Method, Buffers and Rows Removed by Filter. The bar under each node can show self time, total time, rows or cost.

Flame view

The top bar is the whole query; children sit below with widths proportional to their total time. Wide bars low in the stack are where the time goes. Click a bar to open its details.

Hints

- Sequential scan with a filter that removes most rows: suggests CREATE INDEX on the filtered columns. - Index scan followed by a filter that removes many rows: suggests a composite index. - Sort Method external merge or Disk: shows the size and a SET LOCAL work_mem value. - Hash with more than one batch, or a lossy bitmap: work_mem too small. - Nested loop whose inner sequential scan runs more than 1,000 times: index the join column. - Row estimates off by 10× or more: run ANALYZE or add extended statistics. - Planning slower than execution, and JIT on a short query.

Worked example

The sample plan takes 813 ms. Self time shows that 382 ms is the sequential scan on orders, which removes 1,180,298 rows to keep 19,702. The hint proposes CREATE INDEX CONCURRENTLY ON orders (status, created_at). After adding it, the new plan uses an index scan and the query drops to about 60 ms; save both plans to compare.

Limits

Times with parallel workers are averages per loop, so shares in parallel plans are approximate. Hints are rules of thumb, not a guarantee: every index costs write time and disk space, so test on a copy of production data. The tool does not connect to your database; it only reads the text you paste.

Uitgewerkt voorbeeld

813 ms plan: Seq Scan on orders removes 1,180,298 rows → hint CREATE INDEX ON orders (status, created_at) → about 60 ms after the index.

In het kort

Veelgestelde vragen

Which EXPLAIN options should I use?

EXPLAIN (ANALYZE, BUFFERS) gives real times, row counts and cache reads. Add VERBOSE to see output columns, or FORMAT JSON if you prefer.

What is self time?

The time spent in a node itself: its actual total time multiplied by loops, minus the total time of its child nodes.

Why are estimated and actual rows so different?

Usually stale statistics or correlated columns. Run ANALYZE on the table, raise the statistics target, or create extended statistics.

Does it work without ANALYZE?

Yes. Plain EXPLAIN shows estimated costs and rows; time-based views need ANALYZE.

Can I paste output from pgAdmin?

Yes. Quotes, table borders and the trailing row count are cleaned up before parsing.

Is my query sent anywhere?

No. Parsing happens in your browser and saved plans stay in local storage.

Helemaal gratisGeen kosten, geen registratie
Bestanden blijven privéAlles draait in je browser
Makkelijk in je eigen taalBeschikbaar in veel talen