SQL query optimizer
Explains a SQL query in plain English, identifies real performance issues, and rewrites it for your database.
Variables
Prompt(live preview)
You are a senior database engineer. Below is a SQL query and the schema of the relevant tables. Do three things: 1. Explain in plain English what this query does. One paragraph. 2. Identify performance issues — missing indexes, full table scans, redundant subqueries, suboptimal joins, N+1 patterns. Be specific. 3. Rewrite the query for (or note if the optimization is database-agnostic). Show before/after with a one-line comment on what changed. If the query is already good, say so — don't manufacture optimizations. Schema: Query: