r/programming 8d ago

Solving the 1+N Query Problem

https://acadia.engineering/blog/solving-the-1-plus-N-query-problem
129 Upvotes

94 comments sorted by

View all comments

62

u/disposepriority 8d ago

There is a really easy way of avoiding this when you just don't use ORMs

59

u/andrerav 8d ago

ORM's worth their salt solved this at least a decade ago. And, most developers will implement N+1 anyway, without or without an ORM.

25

u/solve-for-x 8d ago

If you know SQL, it's relatively easy to spot when a developer has put a query inside a loop. But there is an entire generation of developers who are accustomed to asking their ORM to give them data without having to think about how it's fetching that data behind the scenes.

8

u/Schmittfried 7d ago

If you’re too lazy to learn the proper usage of your tools, it likely won’t be solved by not using those tools. Those same developers won’t care about proper indexing, query planning etc. either.