$ cat ~/projects/query-plan-analyzer.mdx

Query Plan Analyzer

explain.rezki.dev

A Go tool for reading PostgreSQL and SQL Server query plans, flagging common bottlenecks, and getting an optional LLM explanation.

  • Go
  • PostgreSQL
  • HTMX
  • Docker
  • SQL Server

Context

I kept pasting query plans into a chat to ask what was wrong with them. CLI output is hard to scan, and a generic explanation often misses the database-specific issue. This tool accepts a PostgreSQL or SQL Server plan, points out likely problems, and can ask an LLM to explain the result.

What I built

It is a single Go binary that:

  • Auto-detects whether the input is PostgreSQL EXPLAIN ANALYZE output, JSON, or SQL Server execution plan XML.
  • Runs a rule engine that flags sequential scans, implicit type conversions, missing index recommendations, and planner misestimates. Each rule is a small, testable function — easy to extend per database.
  • Uses HTMX for the few interactive bits (paste, analyze, regenerate) so the whole thing stays server-rendered. No build step, no client framework.

Outcome

I use it first when I am investigating a slow query. The rules catch common problems in under a second. The LLM output is useful when I need to explain a plan to someone who does not work with execution plans every day.