3 ms·
This looks pretty great and I'd definitely consider adding it to new projects, but it's not a magic bullet. You still need to think about what queries this will
by kayodelycaon 4y ago
This looks pretty great and I'd definitely consider adding it to new projects, but it's not a magic bullet. You still need to think about what queries this will trigger and it's a lot less obvious than includes().
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.)