API & MCP

Everything a person can do on Query Plan Visualizer, a program or AI agent can do with the same inputs and get the identical result.

HTTP API

Query Plan Visualizer

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.

Inputs of Query Plan Visualizer
FieldTypeDefaultDescription
texttextarea—EXPLAIN output. 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.
filefile—Or upload the file. Read in memory as UTF-8 text and not stored. Max 5 MiB.
misestimateFactornumber10Flag row misestimates from. Ratio between estimated and actual rows per loop.

Example request

PostgreSQL EXPLAIN ANALYZE: seq scan, disk sort, batched hash

curl -X POST https://queryplanvisualizer.usefulweb.site/api/v1/calculate -H 'content-type: application/json' -d '{"text":"                                                              QUERY PLAN\n-------------------------------------------------------------------------------------------------------------------------------------------\n Sort  (cost=152340.21..153372.39 rows=412873 width=72) (actual time=2211.041..2389.770 rows=412873 loops=1)\n   Sort Key: o.created_at DESC\n   Sort Method: external merge  Disk: 48960kB\n   Buffers: shared hit=1204 read=58210, temp read=12240 written=12268\n   ->  Hash Join  (cost=31250.00..102149.11 rows=5000 width=72) (actual time=402.118..1712.904 rows=412873 loops=1)\n         Hash Cond: (o.customer_id = c.id)\n         ->  Seq Scan on orders o  (cost=0.00..68340.00 rows=5000 width=40) (actual time=0.031..1105.226 rows=412873 loops=1)\n               Filter: ((status = 'shipped'::text) AND (created_at >= '2026-01-01 00:00:00'::timestamp without time zone))\n               Rows Removed by Filter: 4587127\n         ->  Hash  (cost=18750.00..18750.00 rows=1000000 width=36) (actual time=398.402..398.403 rows=1000000 loops=1)\n               Buckets: 262144  Batches: 8  Memory Usage: 9201kB\n               ->  Seq Scan on customers c  (cost=0.00..18750.00 rows=1000000 width=36) (actual time=0.012..141.882 rows=1000000 loops=1)\n Planning Time: 0.412 ms\n Execution Time: 2412.330 ms\n(14 rows)"}'

Every result contains

inputs (normalised, defaults applied), summary, result (validated against the published schema), units, assumptions, sources, warnings, computedAt and links.

MCP (Model Context Protocol)

{
  "mcpServers": {
    "query-plan-visualizer": { "type": "http", "url": "https://queryplanvisualizer.usefulweb.site/mcp" }
  }
}