Diagnose Why a Specific Query Got Slow as a Table Grew

    Updated

    How to use it

    Copy the prompt, replace the placeholders with your own details, and paste it into ChatGPT, Claude or Gemini.

    Save and favourite prompts with a free account.

    Tap any variable to replace it with your own value:

    AI prompt

    Act as a database performance engineer diagnosing why a specific query has gotten slow as a table grew. Database: [Postgres/MySQL/etc.]. The query: [paste the actual SQL]. Table size now vs. when it was fast: [e.g. '50M rows now, was fine under 500K']. I'll paste the query plan if I have one: [paste EXPLAIN ANALYZE output, or say 'no plan available']. Produce: (1) the most likely cause given the query shape and the growth pattern (a missing index, a sequential scan that used to be cheap and now isn't, an N+1 pattern, a join exploding row counts) stated as a specific diagnosis, not a generic checklist; (2) the exact index or query rewrite that would fix it, written out, not just described; (3) how to verify the fix actually worked (what to check in the query plan before and after); (4) whether this fix is safe to apply directly on a live production table or needs a maintenance window, and why.

    Want to support this prompt?

    Share this prompt