Make WordPress Core

Ticket #7415: no_found_rows.diff

File no_found_rows.diff, 1.2 KB (added by ryan, 15 years ago)

Eliminate FOUND_ROWS for post query.

  • wp-includes/query.php

     
    22382238                        $groupby = 'GROUP BY ' . $groupby;
    22392239                if ( !empty( $orderby ) )
    22402240                        $orderby = 'ORDER BY ' . $orderby;
    2241                 $found_rows = '';
    2242                 if ( !empty($limits) )
    2243                         $found_rows = 'SQL_CALC_FOUND_ROWS';
    22442241
    2245                 $this->request = " SELECT $found_rows $distinct $fields FROM $wpdb->posts $join WHERE 1=1 $where $groupby $orderby $limits";
     2242                $this->request = " SELECT $distinct $fields FROM $wpdb->posts $join WHERE 1=1 $where $groupby $orderby $limits";
    22462243                if ( !$q['suppress_filters'] )
    22472244                        $this->request = apply_filters('posts_request', $this->request);
    22482245
     
    22602257                }
    22612258
    22622259                if ( !empty($limits) ) {
    2263                         $found_posts_query = apply_filters( 'found_posts_query', 'SELECT FOUND_ROWS()' );
     2260                        $found_posts_query = apply_filters( 'found_posts_query', "SELECT COUNT($wpdb->posts.ID) FROM $wpdb->posts $join WHERE 1=1 $where" );
    22642261                        $this->found_posts = $wpdb->get_var( $found_posts_query );
    22652262                        $this->found_posts = apply_filters( 'found_posts', $this->found_posts );
    22662263                        $this->max_num_pages = ceil($this->found_posts / $q['posts_per_page']);