Disable Aggregate Count of Query
Hello,
Is there a way to disable to the query that retrieves the aggregate count of the query?
The query starts with:
select count(*) as aggregate from ...// rest of the parameters
I have large datasets and this is causing some slow queries, and I'am not reporting it on some of my views.
Thank you!
As I know about datatables, this is a feature needed for pagination. Checking the code I've seen that it executes the count(*) twice, one to count all records and another to count the filtered records, even if no no filter is applied. I reduced the load time changing the QueryEngine with the next code:
public function totalCount()
{
if(empty($this->search))
return $this->options['counter'];
else
return $this->originalBuilder->count();
}
With this the count(*) is only executed one time -if no filter is applicable- and use the same value for both options, reducing the load time when there are many records. An option to handle the pagination without counting will be appreciated for a future release.
Thank you for this suggestion. I did try implementing it but it doesn't really doesn't help with my slow queries. My database is still examining too many rows. I guess its time to purge my database a bit.