fico7489/laravel-eloquent-join

Question: Why is this not the default in Eloquent?

Closed this issue · 2 comments

I'm just curious as to why there is even a need for this package. I mean why is this not the default way things work in eloquent? I'm not trying to criticize the decision to use multiple selects instead of joins, I'm simply looking for the logic in this design decision.

All the other frameworks and ORMs I've used, all used JOINs, or at least gave the option of choosing the joining strategy. (CakePHP, Django, etc.) Laravel's eloquent is the only one I know which doesn't provide a solution out of the box to use JOINs by default.

Does anyone know why? Is there some benefit to not using JOINs?

Join vs. subquery

subqueries are cleaner, easier to understand, more maintainable, it is easier to separate concerns with subqueries, etc. all pros and cons are on the "subquery" side, except one "SPEED"

take a look on my answer at stackoverflow :

https://stackoverflow.com/questions/2577174/join-vs-sub-query/52465259#52465259

@fico7489 thanks for the answer, although I don't understand how the tradeoff can be made for simpler code at the cost of ditching many useful features.

For me the greatest problem with using subqueries is the inability to order by a related model. It seems like such a common task for example: to list posts and have them ordered by the author's name. But I haven't found a way to do this without using JOINs.