SQL_CALC_FOUND_ROWS is a non-standard MySQL SELECT option. When placed immediately after SELECT, it instructs the optimizer to compute the total number of rows that satisfy the query conditions before LIMIT or OFFSET are applied. The count can then be retrieved by calling the FOUND_ROWS() function in the very next statement within the same session. This technique is commonly used for paginated result sets where both the current page and the overall row count are needed.Internally, MySQL either executes an extra filesort or scans the full result set to compute the count, so queries with SQL_CALC_FOUND_ROWS tend to run slower than the same query without it. For complex JOINs, GROUP BY, or ORDER BY clauses, the performance penalty can be significant. The feature was deprecated in MySQL 8.0.17 and may be removed in future releases. Modern MySQL versions recommend running a separate SELECT COUNT(*) query or using window functions instead.
MySQL 4.0
It directs MySQL to calculate the full number of rows that meet the query conditions before applying any LIMIT or OFFSET so the count can be fetched with FOUND_ROWS().
Yes. Starting in MySQL 8.0.17 the feature is deprecated. Future versions may remove it entirely.
Avoid it on large tables or complex JOINs because it can trigger an expensive full scan or filesort. A separate COUNT(*) query or window function is usually faster.
Use two queries: one SELECT with LIMIT for the page and another SELECT COUNT(*) for the total. In MySQL 8.0+, COUNT(*) OVER() window function can provide both in one query.