🩹Vibe Code Fix

N+1 Query

An N+1 query is a performance anti-pattern where you run one query to fetch a list of N items, then loop and run one more query per item — N additional queries. Your page works fine in development with 5 rows and falls over in production with 5000. AI assistants love generating N+1 because the naive code reads more clearly: `for user in users: user.posts.fetch()`. It's readable, it's wrong. The fix is to fetch related data in a single join or an `IN` query, or use an ORM's eager-loading feature (`.includes()` in Rails, `select_related` in Django, `with` in Prisma). You usually catch it by looking at the query log during manual testing — if clicking one button fires 50 queries, you have one. The nasty thing about N+1 is that small-scale tests won't trip your alerts. It only shows up when real users with real data hit the endpoint, at which point the damage is already done. Our review checklist flags it under performance, weight 'high' — because latency bugs that only appear at scale are the ones that make pages suddenly unusable.

n+1 queryorm performanceeager loadingN+1 쿼리N+1クエリ

Run this against your next diff — the full checklist is on the home page.

Back to checklist