Datatable icon indicating copy to clipboard operation
Datatable copied to clipboard

Disable Aggregate Count of Query

Open whobutsb opened this issue 11 years ago • 2 comments

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!

whobutsb avatar Oct 01 '14 19:10 whobutsb

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.

lugrinder avatar Oct 02 '14 15:10 lugrinder

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.

whobutsb avatar Oct 07 '14 15:10 whobutsb