Skip to content

Allow SQL_CALC_FOUND_ROWS with FOUND_ROWS() instead of SELECT COUNT(*) #2333

Open
@eelco2k

Description

@eelco2k

I've noticed that when having complex DataTables with a lot of joins and filtering, the Count(*) for counting the result rows is slower than the complex query itself. So it would be nice to have an alternative method to use when counting the resulting rows by using the SQL_CACL_FOUND_ROWS in the select. and then afterwards use FOUND_ROWS() query.

i've optimized my tables with correct indexes. And when running the complex query it's only +-20ms. but when the select count(*) from (the_fast_but_complex_ query); runs it's more like 800ms.

But when i do the SELECT SQL_CALC_FOUND_ROWS, * FROM fast_but_complex_query JOIN some_difficult joins etc.
It's +- 20 ms, and the FOUND_ROWS(); query afterwards is only +-5ms.

Which is a major performance hit.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions