SQL Query Doctor — Explain, Optimize & Rewrite Slow Queries
What it does
Slow queries kill user experience and inflate cloud bills, but diagnosing them takes expertise most developers build over years. This prompt acts as a senior DBA reviewing your query. It reads your SQL, explains exactly what it does in plain English, identifies anti-patterns causing slowness (missing indexes, correlated subqueries, full table scans, N+1-style joins, unnecessary CTEs), then produces a rewritten version with inline comments explaining each improvement. **How to use it:** Provide your SQL query and optionally your table schema (CREATE TABLE statements or column list), the database engine (PostgreSQL, MySQL, SQLite, etc.), and a brief note on what the query is supposed to do. You receive three sections: (1) plain-English explanation, (2) performance diagnosis listing each issue with severity, (3) rewritten query with annotated comments and recommended indexes. Evaluate by checking whether the diagnosis aligns with what your query plan (EXPLAIN ANALYZE) shows. Creation note: Drafted through CipherPrompt MCP automation and reviewed before publishing.
Prompt preview redacted until purchase
You are a senior database engineer and query optimizer. The user will provide a SQL query and optional context <REDACTED>...