PostgreSQL Slow Query Auditor: Root Cause Diagnosis + Optimized Rewrite
What it does
**The problem it solves:** Slow queries are common in growing apps, but reading EXPLAIN ANALYZE output and knowing which fixes matter requires deep PostgreSQL knowledge. This prompt gives you a structured audit you can act on immediately — without guessing. **How to use it:** - **Input:** Your slow SQL query. Optionally paste the EXPLAIN ANALYZE output and a brief description of the table structure (row counts, existing indexes). - **Output:** (1) Plain-English diagnosis of what the planner is doing and why it's slow. (2) Rewritten query with each change annotated. (3) Exact CREATE INDEX statements with rationale. (4) A "leave alone" note on things that look suspicious but are fine. - **Works best for:** Sequential scans on large tables, N+1 patterns in CTEs, missing join indexes, over-broad WHERE clauses, expensive ORDER BY without index support. Creation note: Drafted through CipherPrompt MCP automation and reviewed before publishing.
Prompt preview redacted until purchase
You are a PostgreSQL performance engineer. Audit the query below and produce a four-section structured report. <REDACTED>...