Skip to content

Make use of eloquent cache for count #2131

Open
@liepumartins

Description

@liepumartins

Summary of problem or feature request

If one adds some sort of eloquent model caching mechanism, such as laravel-model-caching
data queries are nicely cached and retrieved from cache upon subsequent requests, however count queries (for getting total and filtered count) are not. And every page change triggers those. Since I work with a large dataset, that has some joined tables, both count queries take about 350ms each (data query for page takes about 100ms). Which is why I would want to cache them.
Count does not change that often.

I suspect this happens because counting is done with raw query, instead of using eloquent and count().

$table = $this->connection->raw('(' . $builder->toSql() . ') count_row_table');

System details

  • Operating System Linux
  • PHP Version PHP 7.3.6-1+ubuntu18.04.1
  • Laravel Version 5.8
  • Laravel-Datatables Version 9.0

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions