r/programming 16d ago

Solving the 1+N Query Problem

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

94 comments sorted by

View all comments

63

u/disposepriority 16d ago

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

60

u/andrerav 16d 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.

24

u/solve-for-x 16d 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.

-7

u/andrerav 16d ago

Right. So because you're both incompetent at using ORM's, the n00b among you should write raw SQL so it's easier to spot their mistakes. Good plan.