Title: Minimize dependence on SQL_CALC_FOUND_ROWS
Last modified: July 16, 2021

---

# Minimize dependence on SQL_CALC_FOUND_ROWS

 *  [Pratham](https://wordpress.org/support/users/pratham2003/)
 * (@pratham2003)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/minimize-dependence-on-sql_calc_found_rows/)
 * I’m just looking for opinions / knowledge. I am currently handling a large WooCommerce
   store and frequently come across SQL queries needing optimization.
 * Some of the queries use indexes well but the pagination bit introduces a slight
   delay (usually around 0.5s – 0.9s) due to SQL_CALC_FOUND_ROWS. MySQL ends up 
   using a temporary table + file sort according to `EXPLAIN` on the queries only
   when I add SQL_CALC_FOUND_ROWS.
 * Is there a way to optimize for SQL_CALC_FOUND_ROWS?
 * Do you think it would ever be possible for WordPress / WooCommerce to work in
   an environment where they don’t know the total number of posts (i.e. last page)
   in the backend?
 * Some of my not-well-thought ideas include caching the total pages for some period
   of time on the first execution and then the subsequent pagination queries not
   adding SQL_CALC_FOUND_ROWS to the query. 🤔
    -  This topic was modified 4 years, 9 months ago by [Pratham](https://wordpress.org/support/users/pratham2003/).
    -  This topic was modified 4 years, 9 months ago by [Jan Dembowski](https://wordpress.org/support/users/jdembowski/).
      Reason: Moved to Fixing WordPress, this is not an Everything else WordPress
      topic

Viewing 1 replies (of 1 total)

 *  [hiyottaunits](https://wordpress.org/support/users/hiyottaunits/)
 * (@hiyottaunits)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/minimize-dependence-on-sql_calc_found_rows/#post-14670675)
 * Hi,
 * The SQL_CALC_FOUND_ROWS is depreciated as described below. You can try SELECT
   with LIMIT, and then SELECT COUNT(*).
 * [https://dev.mysql.com/worklog/task/?id=12615](https://dev.mysql.com/worklog/task/?id=12615)

Viewing 1 replies (of 1 total)

The topic ‘Minimize dependence on SQL_CALC_FOUND_ROWS’ is closed to new replies.

## Tags

 * [sql](https://wordpress.org/support/topic-tag/sql/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [hiyottaunits](https://wordpress.org/support/users/hiyottaunits/)
 * Last activity: [4 years, 9 months ago](https://wordpress.org/support/topic/minimize-dependence-on-sql_calc_found_rows/#post-14670675)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
