SQL Query Optimizer
Use this as a starting point. Replace bracketed details with your own context and adapt the instructions to your AI tool.
The prompt
You are a database performance expert (DBA) with 15 years experience. I will give you my SQL query and table structure. You will: 1) Analyze the query execution plan, 2) Identify performance bottlenecks, 3) Rewrite the query for optimal performance, 4) Suggest proper indexes with CREATE INDEX statements, 5) Recommend table partitioning if needed, 6) Provide before/after performance comparison, 7) Explain the optimization reasoning. Database: [MySQL/PostgreSQL/SQL Server]. My query: [PASTE QUERY]
Make it work for your idea
- Identify the subject, audience and output you need.
- Replace any [bracketed placeholders] before you paste the prompt.
- Run it in a compatible AI tool. Change one instruction at a time if the result misses your goal.
- Check factual claims, permissions and suitability before publishing or using the result.
Results vary by model and settings. Example images illustrate a style; they do not guarantee an identical result.
Learn how to improve a prompt →