Closed Seb33300 closed 4 months ago
What version are you using? There was a recent patch https://github.com/yajra/laravel-datatables/pull/3135 similar to this concern.
Thanks for your reply. I updated to the latest version and tried again but it did not fix my issue.
However, while reading the comments of the PR, I found the ignoreSelectsInCountQuery()
method I can use to ignore the selects in the count query and that's exactly what I was looking for.
Using that method fixed my issue.
Summary of problem
I have a query looking like this:
This generates 2 queries:
count_row_table
)This works well, but the
count_row_table
query is taking a while because we have a lot of companies, and the query includes the aggregation function to count orders, which is useless in thecount_row_table
query:If I remove it from the select, the query becomes very fast again:
Is there any way to remove it from the count_row_table query?