Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Count request retrieving whole data set #39

Closed
vedmant opened this issue Oct 2, 2018 · 2 comments
Closed

Count request retrieving whole data set #39

vedmant opened this issue Oct 2, 2018 · 2 comments

Comments

@vedmant
Copy link

vedmant commented Oct 2, 2018

Your code for count is making request and retrieving data for whole table, that will crash on larger tables when it will try to retrieve more than 100k records, you have identical query and count methods:

public function query($query)
{
    $sql = $this->pdo->prepare($query);
    $rows=$sql->execute($this->escape);

    return $sql->fetchAll(PDO::FETCH_ASSOC);
}

public function count($query)
{
    $sql = $this->pdo->prepare($query);
    $rows=$sql->execute($this->escape);

    return $sql->rowCount();
}

All other databables implementation modify query so query itself will count records like select count(*) from table/

@n1crack
Copy link
Owner

n1crack commented Oct 2, 2018

thanks for using the library.

I'm working on 2.0 version of the library. And just updated the count queries for Mysql and Sqlite dbs. (need to test for other dbs/adapters) 6cd56bb
It must be faster. Can you try it with:

composer require ozdemir/datatables:2.0.x-dev

if you have any suggestions please let me know.

@n1crack
Copy link
Owner

n1crack commented Oct 27, 2018

2.0 released. Please let me know if there is any further inconvenience.

@n1crack n1crack closed this as completed Oct 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants