Ticket #10964: simple_modified.10964.diff
File simple_modified.10964.diff, 1.4 KB (added by , 13 years ago) |
---|
-
query.php
2591 2591 $orderby = 'ORDER BY ' . $orderby; 2592 2592 2593 2593 $found_rows = ''; 2594 if ( !$q['no_found_rows'] && !empty($limits) ) 2594 // performance tests have shown that when no grouping is involved, a simple 2595 // count afterwards performs much better on large tables 2596 // http://core.trac.wordpress.org/ticket/10964 2597 if ( !$q['no_found_rows'] && !empty($limits) && !empty($groupby) ) 2595 2598 $found_rows = 'SQL_CALC_FOUND_ROWS'; 2596 2599 2597 2600 $this->request = " SELECT $found_rows $distinct $fields FROM $wpdb->posts $join WHERE 1=1 $where $groupby $orderby $limits"; … … 2634 2637 } 2635 2638 2636 2639 if ( !$q['no_found_rows'] && !empty($limits) ) { 2637 $found_posts_query = apply_filters_ref_array( 'found_posts_query', array( 'SELECT FOUND_ROWS()', &$this ) ); 2640 $found_posts_query = "SELECT FOUND_ROWS()"; 2641 if ( empty( $groupby ) ) 2642 $found_posts_query = "SELECT count(*) FROM $wpdb->posts $join WHERE 1=1 $where $orderby"; 2643 $found_posts_query = apply_filters_ref_array( 'found_posts_query', array( $found_posts_query, &$this ) ); 2638 2644 $this->found_posts = $wpdb->get_var( $found_posts_query ); 2639 2645 $this->found_posts = apply_filters_ref_array( 'found_posts', array( $this->found_posts, &$this ) ); 2640 2646 $this->max_num_pages = ceil($this->found_posts / $q['posts_per_page']);