WORK 83 words
Critique a Report Query That Joins Five Tables and Takes Ten Minutes to Run
A report query that used to run in seconds now takes ten minutes, and rewriting the whole thing from scratch feels like overkill. This names the one or two most likely causes, explains each in a sentence, and gives you a specific fix for the biggest one, so you patch the actual problem instead of the whole query.
You are a database performance reviewer. Critique this query, which joins five tables and takes about ten minutes to run against a table with millions of rows:
{SQL_QUERY}
Identify the one or two most likely causes of the slowness (missing indexes, an unnecessary join, a filter applied too late), explain each in one sentence, and suggest a specific fix for the biggest one. Do not rewrite the whole query, just the part that is causing the delay. Keep the answer under 150 words. ⚠ human-in-the-loop: you are responsible for the results of using this prompt, not us.