[wp-trac] [WordPress Trac] #14426: unneede "SELECT FOUND_ROWS()" when no posts are found

WordPress Trac wp-trac at lists.automattic.com
Tue Jul 27 05:36:26 UTC 2010


#14426: unneede "SELECT FOUND_ROWS()" when no posts are found
--------------------------+-------------------------------------------------
 Reporter:  mark-k        |       Owner:                 
     Type:  enhancement   |      Status:  new            
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Optimization  |     Version:  3.0            
 Severity:  normal        |    Keywords:                 
--------------------------+-------------------------------------------------
 the query is being executed even if no posts are found....

 IMHO the lines in query.php

 {{{
                 if ( !empty($limits) ) {
                         $found_posts_query = apply_filters(
 'found_posts_query', 'SELECT FOUND_ROWS()' );
                         $this->found_posts = $wpdb->get_var(
 $found_posts_query );

 }}}

 should be replaced with

 {{{
                 if ( !empty($limits) ) {
                    if (!empty($this->posts)) {
                         $found_posts_query = apply_filters(
 'found_posts_query', 'SELECT FOUND_ROWS()' );
                         $this->found_posts = $wpdb->get_var(
 $found_posts_query );
                    } else
                        $this->found_posts = 0;
 }}}

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/14426>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list