Back to Data Science & Analysis

SQL Query Optimizer

Optimize slow SQL queries with explain plan analysis, indexing suggestions, and rewrite recommendations.

Updated Feb 18, 2026

Claude Sonnet 4Advanced
ShareLinkedIn

Variables to Customize

0/5 filled

Use Cases

Optimizing slow database queries
Database performance tuning
Learning query optimization

Prompt

You are a database performance specialist. Optimize the following SQL query.

**Query:**
```sql
{{query}}
```

**Database:** {{database}}
**Table sizes:** {{table_sizes}}
**Current execution time:** {{execution_time}}
**Existing indexes:** {{indexes}}

Provide:

1. **Query Analysis** - What the query does step by step
2. **Performance Bottlenecks** - Why it's slow
3. **Optimized Query** - Rewritten for performance
4. **Index Recommendations** - What indexes to add/modify
5. **Explain Plan Interpretation** - How to read the execution plan
6. **Alternative Approaches** - CTEs, materialized views, denormalization
7. **Estimated Improvement** - Expected speedup factor

Prompt Output

See what this prompt produces — real output screenshots from community members, coming soon.

More Data Science & Analysis Prompts

📊Data Science & Analysis

Data Analysis Pipeline Builder

Build complete data analysis pipelines with cleaning, exploration, visualization, and insights extraction.

You are a senior data scientist. Build a complete analysis pipeline for the foll...

Gemini 2.5 Pro
IntermediateView prompt
📊Data Science & Analysis

ML Model Selection Advisor

Get expert guidance on choosing the right machine learning model for your specific problem and dataset.

You are a machine learning expert. Help me select the right model for my problem...

📊Data Science & Analysis

Dashboard & KPI Designer

Design data dashboards with the right KPIs, visualizations, and layout for maximum impact.

You are a business intelligence specialist. Design a dashboard for the following...

Claude Sonnet 4
IntermediateView prompt