Back to Developers
Developerssqldatabase-tuningperformance
Advanced SQL Query Performance Tuner
Analyzes slow SQL queries, explains performance bottlenecks, and provides optimized query rewrites along with index recommendations.
Use Case
Use this when database queries are slowing down application response times or consuming too much CPU.
AI Prompt
Act as an expert Database Administrator (DBA). Analyze the following slow SQL query and its execution plan (if available). Rewrite the query to optimize execution speed, reduce resource consumption, and prevent full table scans. Provide a clear list of recommended indexes and explain why specific bottlenecks (such as subqueries, joins, or filters) were addressed. Query: [insert query and optionally execution plan here]
How to Use
- 1Copy your slow SQL query and paste it into the placeholder.
- 2Include the execution plan if you have access to it for better results.
- 3Run the prompt and apply the optimized query and indexes to your database.
Example Output
The optimized query replaces the slow subquery in the WHERE clause with an inner join on the order stats table. We recommend adding a composite index on the orders table using the customer id and status columns to avoid a sequential scan. This change will allow the database engine to perform index seeks instead.
Related Prompts
View AllHigh-Performance Database Query Optimizer
Identifies bottlenecks, suggests indexes, and rewrites slow-running SQL queries for optimal performance.
sqldatabasequery-optimization
View Prompt
Performance Bottleneck & Profiler Analyst
Pinpoints execution hotspots, memory leaks, and inefficient algorithms in complex code snippets.
performanceoptimizationbig-o
View Prompt
High-Performance SQL Query Tuner
Analyzes sluggish database queries and returns optimized versions, detailing execution plan improvements.
sqldatabaseperformance
View Prompt