n1crack / datatables

Simplify your Datatables server-side processing effortlessly using our lightning-fast PHP library, streamlining your workflow seamlessly.
https://datatables.ozdemir.be/
MIT License
267 stars 90 forks source link

Large Table Count #101

Closed 13ran closed 5 months ago

13ran commented 5 months ago

Would it be possible to add a way to turn off the count query or provide my own count? I have a table with millions of rows and it causes very slow execution/ timeouts

n1crack commented 5 months ago

Yes it is possible. When setting setTotalRecords, it doesnt run the count statement for the full query.

    $path = dirname(__DIR__).'/database/Chinook_Sqlite_AutoIncrementPKs.sqlite';

    $dt = new Ozdemir\Datatables\Datatables(new Ozdemir\Datatables\DB\SQLite($path));
    $dt->query('Select TrackId, Name, UnitPrice from Track');

    $dt->setTotalRecords(3503);
    return $dt->generate();
13ran commented 5 months ago

Thank you!