$ cat ~/projects/query-plan-analyzer.mdx
Query Plan Analyzer
A multi-database query plan visualizer with auto-detection, rule-engine bottleneck detection, and AI-powered analysis via 5 LLM providers.
- Go
- PostgreSQL
- HTMX
- Docker
- SQL Server
Context
Every backend engineer I know has, at some point, pasted a query plan into a chat and asked "what's wrong with this?" The usual answer is a wall of text or a screenshot from a CLI tool that doesn't render well in a browser. I wanted a single tool that takes a plan from either PostgreSQL or SQL Server, highlights the actual problems, and lets an LLM explain them in plain language.
What I built
A single Go binary that:
- Auto-detects whether the input is PostgreSQL
EXPLAIN ANALYZEoutput, 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.
- Streams AI analysis back via SSE (server-sent events), so suggestions appear token-by-token. Five providers are wired in (OpenAI, Anthropic, OpenRouter, OpenCode) with a normalized request shape so adding a new one is roughly 20 lines.
- Uses HTMX for the few interactive bits (paste, analyze, regenerate) so the whole thing stays server-rendered. No build step, no client framework.
The deployment story matters: one docker run, no frontend pipeline, no environment-specific bundling.
Outcome
The tool is what I reach for first now when I'm staring at a slow query. The rule engine catches the boring problems in under a second, and the LLM pass is the part I can hand to a teammate who doesn't read execution plans fluently.
If I were starting over I'd probably keep the same shape but write the rule engine as data (YAML/JSON) instead of Go functions — it'd be easier for non-Go contributors to add rules.