Description
I encountered this bug when i tried a groupBy
and pagination on a query which had joins, eloquent fkin pulls allll the damn results of the query into memory, which for any non-trivially joint query, are a LOT, and brings the app to a crawl, and for more than smallish join, it puts the system to a halt.
What more, when you have joins on your queries, the paginator somehow even ignores the distinct clause and gives you a huge number of total results.
The solution is pretty simple, when a query has groups
, just wrap it in a sub-query and apply the aggregate via the super-query. This is something i tackled in l3 and it worked perfectly. But it was ignored over there too. Here is the link to the PR laravel/laravel#1360
I don't have time right now, but would be sending a PR for the same today itself, but would be great if its noticed this time.