Prompt #118
Back to promptsDatabase Query Optimizer
- Variables
- database, query, table_stats
- Tags
- sql,database,performance,optimization
- Source
- research-2026-05-01
- Use count
- 0
- Created
- 2026-05-01T18:11:52.162090+00:00
- Updated
- 2026-05-01T18:11:52.162090+00:00
Content
Analyze and optimize the following SQL query for {{database}}.
```sql
{{query}}
```
Table sizes: {{table_stats}}
Analysis:
1. Current execution plan (EXPLAIN output interpretation)
2. Performance bottlenecks identified
3. Missing indexes (with CREATE INDEX statements)
4. Query rewrite suggestions (with benchmark expectation)
5. N+1 query patterns to eliminate
6. Caching opportunities
Provide the optimized query with inline comments explaining each change.