Coding GPT-5.2 Advanced PRO

SQL query optimizer & explainer

Explains why a slow query is slow and rewrites it with proper indexes.

The Prompt
Analyse the SQL query below on {DIALECT}. Provide:
1. Plain-English explanation of what it does
2. Estimated worst-case complexity
3. 3 likely bottlenecks (with reasoning)
4. A rewritten version + suggested indexes (CREATE INDEX statements)

```sql
{QUERY}
```