Database Optimizer: AI Driven Postgres Diagnostics
Database Optimizer is an AI powered PostgreSQL performance assistant built to simplify one of the most frustrating parts of backend development: interpreting EXPLAIN ANALYZE execution plans.Instead of manually tracing complex execution trees and guessing which indexes or query changes will improve performance, developers can paste their SQL query together with its execution plan into the app. The AI analyzes the plan like an experienced Database Administrator, identifies the exact bottleneck, whether it's Sequential Scans, inefficient Nested Loops, Hash Joins, memory spills, or inaccurate row estimates, and generates a production safe optimization. Every generated index uses CREATE INDEX CONCURRENTLY, ensuring live PostgreSQL tables remain available without locking production traffic. When indexing isn't the best solution, the AI intelligently rewrites the query to improve execution efficiency. I built this because optimizing PostgreSQL queries is often time consuming and error prone, especially for developers who don't specialize in database performance. My goal was to create a fast, zero friction tool that transforms raw execution plans into safe, actionable SQL with a single click, helping developers ship performant applications with confidence.
Tech stack
- ChatGPT
- Claude
- Claude Code
- Vercel
Links
Prompt
You are an expert PostgreSQL Database Administrator (DBA) specializing in query execution plans and high-throughput index optimization.
Your task is to analyze a raw SQL query alongside its corresponding PostgreSQL EXPLAIN ANALYZE text or JSON execution plan payload.
CRITICAL OBJECTIVES:
1. Pinpoint the exact physical operator causing performance degradation (e.g. Seq Scan, high-cost Nested Loop, Hash Join spilling to disk, high actual loops vs estimated rows).
2. Generate a precise, non-destructive optimization remedy.
OUTPUT REQUIREMENTS:
- Return ONLY a clean SQL code block.
- Do not include explanations or conversational text.
- If creating an index, ALWAYS use CREATE INDEX CONCURRENTLY.
- If a query rewrite is required, output the fully optimized SQL.
- Ensure all identifiers match the execution plan exactly.
If the input is invalid or missing an execution plan, return:
-- ERROR: Invalid query execution plan payload. Please provide valid EXPLAIN ANALYZE output.
4 likes · 1 comment · 10 views
Comments (1)
This is one of those tools that sounds boring until you need it at 1 AM. Explaining the plan clearly is honestly half the battle with Postgres.