title: Disable SQL_CALC_FOUND_ROWS with Pagination
body: <p>I want to disable Disable SQL_CALC_FOUND_ROWS with Pagination. For that purpose, i am using the following code from <a href="https://wpartisan.me/tutorials/wordpress-database-queries-speed-sql_calc_found_rows" rel="nofollow noreferrer">SQL_CALC_FOUND_ROWS</a> but due to that code pagination not working. How i do this or how to improve below code? </p>
  
  <pre><code>if ( ! function_exists( 'oz_optimized_get_posts' ) ):
  function oz_optimized_get_posts() {
      global $wp_query, $wpdb;
  
      $wp_query-&gt;query_vars['no_found_rows'] = 1;
      $wp_query-&gt;found_posts = $wpdb-&gt;get_var( "SELECT COUNT(*) FROM wp_posts WHERE 1=1 AND wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private')" );
      $wp_query-&gt;found_posts = apply_filters_ref_array( 'found_posts', array( $wp_query-&gt;found_posts, &amp;$wp_query ) );
  
      $posts_per_page = ( ! empty( $wp_query-&gt;query_vars['posts_per_page'] ) ? $wp_query-&gt;query_vars['posts_per_page'] : get_option( 'posts_per_page' ) );
      $wp_query-&gt;max_num_pages = ceil( $wp_query-&gt;found_posts / $posts_per_page );
  
      return $wp_query;
  }
  add_filter( 'pre_get_posts', 'oz_optimized_get_posts', 100 );
  endif;
  </code></pre>