The DataLoader Pattern: Eliminating N+1 Queries Without an ORM

The N+1 query problem gets blamed on ORMs. Fix your lazy loading, add eager: true, reach for a JOIN. But N+1 isn't an ORM problem — it's a structural problem that surfaces whenever data is fetched inside a loop. GraphQL resolvers, REST endpoints composing multiple services, React Server Components making per-row database calls: the pattern is everywhere, and the ORM is just the messenger.

The fix isn't always a JOIN. Sometimes data lives in different services. Sometimes you're calling a third-party API. The DataLoader pattern — originally from Facebook's GraphQL infrastructure — solves this at the right abstraction layer, without collapsing your resolver boundaries.