What is N+1 Query Problem?
A performance bug where fetching a list triggers one query per item — N extra queries — instead of a single batched query.
Definition
The N+1 problem occurs when code loads a list with one query, then lazily loads a relation for each item, issuing N additional queries — fetching 100 posts and then 100 separate author lookups. Each query is fast, so the pathology hides until list sizes or latency grow. ORMs cause it silently via lazy loading; the fixes are eager loading (Active Record's includes, SQLAlchemy's selectinload, Prisma's include), a JOIN, or batching with a DataLoader, the standard remedy in GraphQL resolvers. Query logging or APM traces showing bursts of identical queries are the telltale diagnostic.

