SQL Query Optimisation

Review and optimise a slow or inefficient SQL query, explaining the performance issues found and rewriting it with best-practice structure and indexing guidance.

Data AnalystClaudeCo-PilotChatGPTGeminiMidUpdated Mar-26
172·

Prompt

I have a SQL query that is running slowly or producing unexpected results. Please help me optimise it. Database: Approximate table sizes: Current runtime: What the query is supposed to do: Please: 1. Identify all performance issues — inefficient joins, missing indexes, unnecessary subqueries, full table scans, etc. 2. Explain each issue in plain language 3. Rewrite the query with optimisations applied 4. Annotate the rewritten query with comments explaining key changes 5. Recommend any indexing or schema changes that would further improve performance 6. Flag any logic errors or edge cases in the original query that could produce incorrect results Take a moment to ask me any questions before starting if it would lead to a better result.

Sign in to save the prompt