Open dlnsk opened 9 years ago
Thanks for this PR, @dlnsk...
Next commit (1853d41) fix wrong count when groupBy used in query.
hey @dlnsk your first commit it's doing the same thing that i did here: https://github.com/Chumper/Datatable/pull/348 ?
@dlnsk did you try setting the noGroupByOnCount
option on QueryEngine
? This should remove the group by before doing the count, which should lead to having the correct table count.
Doing:
return \DB::table(\DB::raw('('.$originalBuilder->toSql().') as temp_tbl'))
->mergeBindings($originalBuilder->getQuery())
->count();
is not good, because it means a full table scan will need to be done for each search, sort and count, which will be extremely slow (http://dev.mysql.com/doc/refman/5.7/en/subquery-optimization.html)
@timgws it isn't the same. When I use groupBy I want know how many groups there are. Not how many items in all groups which noGroupByOnCount
gives.
I can use setSearchWithAlias()
but in my opinion it should be slower than subquery because need to send hundreds or even thousands records through network layer for php's count()
. And it gives wrong result for language.infoFiltered
("filtered from MAX total entries") message.
@Javier-Rotelli yes ;o) but in little less lines
true :p in this commit e035066 is a test for that functionality. maybe it helps
@Javier-Rotelli thanks but it already in main develop branch
Can't pass function name through setCallbacks because it encoding as option.