No More N+1. Period
evgeniydemin.medium.com
evgeniydemin.medium.com
If you have a large application with an ORM like Active Record, you'll often end up in situations where queries inside methods trigger the N+1 problem. Sometimes this loading is highly conditional. You end up trading the N+1 problem for a "loading an entire unnecessary table" problem.
I suspect this is the reason this feature hasn't been added to Active Record. It would be used a lot when it's only narrowly useful and has worse side effects. (It's also yet one more layer of complexity on top of an already complex ORM.)
"The moment I heard my opponent in the debate speaking in the vulgar dialect, I knew at once I could dismiss their arguments as those made by The Wrong Sort Of People. If they were serious about politics, they would have gone to a proper Public School."
What kind of image would you suggest I have on posts like this?
So far, I see that N+1 is a "measurable" problem that doesn't have to be removed with an additional layer of hidden complexity.
you shouldn't worry about n+1 issues until you have a verified perf issue in your app
if you have paging and N is relatively small, the additional complexity may not be worth it (although ActiveRecord makes it very easy to tweak locally as needed, which is the right thing)
what is important in my opinion is a server side framework is logging of perf related details out of the box:
- show how long each request takes and flag slow ones - show what queries occur in each request
The more humane formatting of these logs, the better...