N+1 Query Problem
On this page
What Is N+1
N+1 occurs when fetching a list and then querying related data individually for each item.
Example Problem
SELECT * FROM users; -- then for each user: SELECT * FROM orders WHERE user_id = ?
Solution
Use JOINs or batch queries to reduce round trips.
Production Insight
N+1 often appears after refactoring into repository layers. Monitor query counts per request.