InletDownload

EXPLAIN plan visualizer

Paste a PostgreSQL query plan to see it as a tree: how long each step took on its own, which one is the slowest, and where the planner’s row estimates were far off. Free, and it runs in your browser.

Read in your browser. Nothing is uploaded.

Get a plan

Run your query with EXPLAIN (ANALYZE, BUFFERS) in front of it, and paste everything it prints:

EXPLAIN (ANALYZE, BUFFERS)
SELECT u.name, count(*)
FROM users u JOIN orders o ON o.user_id = u.id
GROUP BY u.id;

ANALYZE runs the query for real to time each step. For an INSERT, UPDATE or DELETE, wrap it in a transaction you roll back:

BEGIN;
EXPLAIN (ANALYZE, BUFFERS) UPDATE orders SET status = 'shipped' WHERE id = 42;
ROLLBACK;

Text output and FORMAT JSON both work, with or without psql’s frame around them. Without ANALYZE, the visualizer shows the planner’s estimated costs instead of times.

Reading the result

  • Own time is the time a step spent itself: its total minus its children’s. The bars compare steps by it, and the step with the most is marked slowest. Start there.
  • Rows shows how many rows a step really returned beside how many the planner expected. A badge like ↑ 120× means the planner expected far fewer rows. Bad estimates lead to bad plans (a nested loop over thousands of rows instead of a hash join, say), and they usually come from stale statistics: run ANALYZE <table>.
  • Loops: a step under a nested loop runs once per outer row. Its time per loop is multiplied by the loops.
  • Click a step to see its details: filters, rows removed, buffers, sort and hash memory. Each step’s name links to what it does and when it’s a problem.

Private by design

The plan is read by this page, in your browser. It isn’t uploaded or stored. Copy a link puts the plan, compressed, in the part of the address after the #, which browsers never send to a server.

In Inlet, the free Mac database client, ⌘E explains the query under the cursor and draws the same tree, with the slowest step and the worst estimates highlighted, without leaving the editor.