Skip to content

Replace usage of SQL_CALC_FOUND_ROWS #3079

@brianhogg

Description

@brianhogg

SQL_CALC_FOUND_ROWS is deprecated in MySQL. Instead, wrap calls with a SELECT COUNT() query or refactor to have COUNT() in the main query, depending.

We'll want to search for all instances of get_found_results or SQL_CALC_FOUND_ROWS in the codebase to replace with COUNT(*) instead.

A new count_only param was introduced specifically for the student query in #3075 . We may want to add a new get_count() or something to make it clearer in the code we're not using the SQL_CALC_FOUND_ROWS value.

Plan:

  1. Find all instances of SQL_CALC_FOUND_ROWS and get_found_results()
  2. Change the query to have COUNT(*) in the main SELECT clause, wrap in a new SELECT COUNT(*) FROM ( ... original query ... ), or add the count_only param to the query object being created.
  3. Remove/deprecate adding of SQL_CALC_FOUND_ROWS to any queries
  4. Test all changes return the correct counts

Metadata

Metadata

Assignees

Labels

Type: EnhancementImprovements existing features or code

Type

No type

Projects

Status

To do

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions