SQL Explain Plan Visualizer

Parse EXPLAIN / EXPLAIN ANALYZE output (PostgreSQL/MySQL/SQLite) into a cost tree, flag estimated-vs-actual row divergence, and suggest indexes

Parses real EXPLAIN output (PostgreSQL JSON or TEXT, MySQL JSON or classic table, SQLite QUERY PLAN) into an indented, color-coded cost tree showing node type, relation, index, cost, estimated rows, and actual rows/timing (from EXPLAIN ANALYZE). Diagnostics flag sequential scans, statistics divergence, filesorts, temporary tables, non-sargable predicates, and more — each with concrete index/rewrite suggestions.

Example Results

1 examples

Visualize a PostgreSQL EXPLAIN ANALYZE with row-estimate divergence

A Seq Scan whose estimate (1000) is far below actual rows (95000) — a classic stale-statistics hotspot, with an index suggestion.

Execution plan tree with divergence hotspot and index suggestion.
View input parameters
{ "explainOutput": "[\n {\n \"Plan\": {\n \"Node Type\": \"Seq Scan\",\n \"Relation Name\": \"users\",\n \"Alias\": \"users\",\n \"Filter\": \"((email)::text = '[email protected]')\",\n \"Plan Rows\": 1000,\n \"Plan Width\": 142,\n \"Total Cost\": 1541.00,\n \"Actual Rows\": 95000,\n \"Actual Loops\": 1,\n \"Actual Startup Time\": 0.1,\n \"Actual Total Time\": 12.4\n }\n }\n]", "dialect": "auto", "sql": "SELECT * FROM users WHERE lower(email) = '[email protected]'", "maxDepth": 20 }

Key Facts

Category
Developer & Web
Input Types
textarea, select, number
Output Type
html
Sample Coverage
4
API Ready
Yes

Overview

The SQL Explain Plan Visualizer parses raw EXPLAIN and EXPLAIN ANALYZE outputs from PostgreSQL, MySQL, and SQLite into an interactive, color-coded cost tree. It highlights performance bottlenecks, flags significant discrepancies between estimated and actual row counts, and provides actionable index and query rewrite recommendations.

When to Use

  • When a database query is running slowly and you need to pinpoint the exact node causing the bottleneck.
  • When you suspect stale database statistics are causing the query planner to choose inefficient scan methods.
  • When analyzing complex, nested execution plans that are difficult to read in raw text or JSON formats.

How It Works

  • Paste your raw EXPLAIN or EXPLAIN ANALYZE output (JSON or text format) into the input area.
  • Select your database dialect (PostgreSQL, MySQL, or SQLite) or let the tool auto-detect it.
  • Optionally input the original SQL query to help the visualizer generate precise index recommendations.
  • Analyze the generated tree diagram to identify high-cost nodes, sequential scans, filesorts, and row-estimate divergences.

Use Cases

Visualizing complex PostgreSQL JSON execution plans to locate high-cost sequential scans.
Detecting stale table statistics by highlighting large gaps between estimated and actual row counts.
Optimizing slow MySQL queries by identifying temporary tables and filesorts in the execution tree.

Examples

1. Diagnosing Stale Statistics in PostgreSQL

Database Administrator
Background
A user search query on a PostgreSQL database is taking several seconds despite having an index on the email column.
Problem
The query planner is choosing a sequential scan over an index scan because it estimates only 1,000 rows, but the table actually returns 95,000 rows.
How to Use
Paste the PostgreSQL EXPLAIN ANALYZE JSON output into the tool, set the dialect to PostgreSQL, and input the SQL query.
Example Config
{
  "dialect": "postgresql",
  "sql": "SELECT * FROM users WHERE lower(email) = '[email protected]'",
  "maxDepth": 20
}
Outcome
The visualizer highlights the Seq Scan node in red, flags the 95x row divergence, and suggests running ANALYZE to update table statistics.

2. Identifying Filesorts in MySQL Queries

Backend Engineer
Background
An API endpoint sorting user records by creation date is experiencing high latency under load.
Problem
The MySQL execution plan shows a filesort operation, indicating that the database is sorting rows in memory or on disk instead of using an index.
How to Use
Run EXPLAIN FORMAT=JSON on the query, paste the JSON output into the visualizer, and select MySQL as the dialect.
Example Config
{
  "dialect": "mysql",
  "maxDepth": 15
}
Outcome
The tool displays a cost tree highlighting the filesort node and recommends creating a composite index on the filtered and sorted columns.

Try with Samples

json, sql, text

Related Hubs

FAQ

Which database dialects and formats are supported?

The tool supports PostgreSQL (JSON and text), MySQL (JSON and tabular), and SQLite (QUERY PLAN text).

How does the tool identify stale database statistics?

It compares the estimated plan rows with the actual rows from EXPLAIN ANALYZE; a difference of 10x or more flags a statistics hotspot.

Do I need to provide the original SQL query?

No, the SQL query is optional, but providing it allows the tool to suggest specific index columns and query rewrites.

What types of query bottlenecks are flagged?

It flags sequential scans on large tables, filesorts, temporary tables, expensive nested loops, and non-sargable predicates.

Is my query plan data sent to an external server?

No, all parsing and visualization are performed locally in your browser to ensure data privacy.

API Documentation

Request Endpoint

POST /en/api/tools/sql-explain-plan-visualizer

Request Parameters

Parameter Name Type Required Description
explainOutput textarea Yes -
dialect select No -
sql textarea No -
maxDepth number No -

Response Format

{
  "result": "
Processed HTML content
", "error": "Error message (optional)", "message": "Notification message (optional)", "metadata": { "key": "value" } }
HTML: HTML

AI MCP Documentation

Add this tool to your MCP server configuration:

{
  "mcpServers": {
    "elysiatools-sql-explain-plan-visualizer": {
      "name": "sql-explain-plan-visualizer",
      "description": "Parse EXPLAIN / EXPLAIN ANALYZE output (PostgreSQL/MySQL/SQLite) into a cost tree, flag estimated-vs-actual row divergence, and suggest indexes",
      "baseUrl": "https://elysiatools.com/mcp/sse?toolId=sql-explain-plan-visualizer",
      "command": "",
      "args": [],
      "env": {},
      "isActive": true,
      "type": "sse"
    }
  }
}

You can chain multiple tools, e.g.: `https://elysiatools.com/mcp/sse?toolId=png-to-webp,jpg-to-webp,gif-to-webp`, max 20 tools.

If you encounter any issues, please contact us at [email protected]