15 ms·
This seems very situation specific. If you write lots of fun queries, I see how it may not be that useful. But the most common case for people is honestly going
by viraptor 2y ago
This seems very situation specific. If you write lots of fun queries, I see how it may not be that useful. But the most common case for people is honestly going to be User.find(id=params.id) and Things.find(owner=user). That's like 99.9% of the internet. Saving the time of writing that trivial query and dealing with the result is perfect for ORMs.
> And they're always lazy, so you never really know when the N+1s are going to happen.
There are tools to detect this. Please use them regardless. Even if you're writing queries but hand, enough functions on the stack can hide an N+1
- benwilber0 2y agoI'm not talking about trivial applications. PK lookups are easy no matter what you use. I'm talking about non-trivial applications. > > And they're always lazy, so you never really know when the N+1s are going to happen. > There are tools to detect this. Please use them regardless. Even if you're writing queries but hand, enough functions on the stack can hide an N+1 I don't want to have to use a tool to "detect" anything. I want my queries to return exactly what they're expected to return, or my code will fail. No surprises.
- mobiuscog 2y agoI think the purpose of the tool is to detect the unexpected number of additional queries, not what is returned.