Back to Developers
Developerssqldatabaseperformance
SQL Query Analyzer and Performance Tuner
Diagnoses slow-running SQL queries and provides highly optimized query versions along with exact indexing recommendations.
Use Case
Use this prompt when database queries are slowing down application response times or consuming excessive server CPU and memory.
AI Prompt
Act as an expert Database Administrator (DBA). Analyze the following SQL query and its execution parameters. Rewrite the query to achieve maximum execution speed and minimum resource consumption. Explain the performance bottlenecks in the original query (such as subqueries, wildcard searches, or full table scans) and provide the exact CREATE INDEX statements required to optimize performance. SQL Query: [insert SQL query here] Optional Schema/Execution Plan Details: [insert database schema or EXPLAIN plan output here]
How to Use
- 1Paste the slow-performing SQL query.
- 2Provide database schema information, constraints, or EXPLAIN plan data if available.
- 3Implement the suggested index queries on your development database and verify the performance improvements.
Example Output
The original query suffered from performance degradation due to an implicit conversion in the WHERE clause and a correlated subquery. By rewriting the subquery into an inner join on the indexed user ID column and using explicit typecasting, execution speed is increased. Additionally, you should run the create index statement on the users table targeting both email and status columns.
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