Debug and optimize slow database queries
Help me debug and optimize a slow database query.
**Database system:** {{DATABASE}}
**Slow query:**
```sql
{{QUERY}}
```
**Query execution plan/EXPLAIN output:**
```
{{EXPLAIN_OUTPUT}}
```
**Table schemas involved:**
```sql
{{SCHEMAS}}
```
**Current execution time:** {{CURRENT_TIME}}
**Expected/target execution…Premium Prompt
Unlock this prompt — and all 30,000+ expert-crafted prompts — with Pro.
Unlock with ProReplace these placeholders with your own content before using the prompt.
[{DATABASE][{QUERY][{EXPLAIN_OUTPUT][{SCHEMAS][{CURRENT_TIME]