[wp-trac] [WordPress Trac] #10964: Improving query_posts performance
WordPress Trac
wp-trac at lists.automattic.com
Fri Oct 16 13:24:58 UTC 2009
#10964: Improving query_posts performance
-------------------------+--------------------------------------------------
Reporter: buch0090 | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: 2.9
Component: Performance | Version: 2.8.4
Severity: normal | Keywords: query_posts, performance
-------------------------+--------------------------------------------------
Comment(by buch0090):
First post was a little jumbled, here are code changes..
In wp-includes/query.php, starting at line 2251...
//////// BELOW CODE MODIFIED BY DAVE BUCHANAN, SPLIT INTO TWO QUERIES
if ( !empty($limits) )
$found_rows = 'SQL_CALC_FOUND_ROWS';
/// FIRST SELECT JUST IDs
$tmp = " SELECT $distinct $wpdb->posts.id FROM $wpdb->posts $join WHERE
1=1 $where $groupby $orderby $limits";
$tmp_q = $wpdb->get_col($tmp);
$tmp_ids = implode($tmp_q,',');
/// NOW NORMAL SELECT WHERE ID IS IN FIRST QUERY LIST
$this->request = " SELECT $found_rows $distinct $fields FROM $wpdb->posts
$join WHERE $wpdb->posts.id IN ($tmp_ids) $groupby $orderby ";
if ( !$qsuppress_filters? )
$this->request = apply_filters('posts_request', $this->request);
$this->posts = $wpdb->get_results($this->request);
--
Ticket URL: <http://core.trac.wordpress.org/ticket/10964#comment:1>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list