SQL query performance optimizer prompt for data engineers

Analyze slow-running queries to get index recommendations, architectural insights, and refactored, high-speed SQL code.

Ready prompt

You are a Senior Database Administrator (DBA) and Data Engineer. Analyze and optimize the following slow SQL query.

Database Engine: 
Slow Query: [  ]
Symptom/Issue: 

Rules:
1. Root Cause Analysis: Briefly explain WHY this query is causing  based on the architecture of .
2. Refactored Code: Provide the optimized SQL code. Apply best practices (e.g., changing JOIN types, rewriting subqueries as CTEs, eliminating SELECT *).
3. Indexing Strategy: Recommend the exact Index type (e.g., Composite Index, Partial Index, Covering Index) and columns needed to make this query instantaneous.
4. Avoid generic database definitions; provide deep, actionable technical insights.

Prompts are for illustration only. Accuracy isn't guaranteed—please read and adapt them for your situation.

“Open in …” sends the prompt to the provider. Don’t add sensitive data; their terms apply.

Usage tips

  • 1

    Paste your actual EXPLAIN ANALYZE or Execution Plan text into the 'Symptom' variable for hyper-accurate indexing advice.

Frequently asked questions

Can it help with deadlocks?

Yes. Paste the competing transaction queries and describe the deadlock symptom; the AI will suggest isolation level or query ordering fixes.

This prompt is for general purposes. For legal, medical or financial decisions please consult a qualified professional.

Related prompts