[wp-trac] [WordPress Trac] #18536: Improve performance of WP_Query core

WordPress Trac wp-trac at lists.automattic.com
Fri Mar 9 20:06:44 UTC 2012


#18536: Improve performance of WP_Query core
----------------------------+------------------
 Reporter:  cheald          |       Owner:
     Type:  task (blessed)  |      Status:  new
 Priority:  normal          |   Milestone:  3.4
Component:  Performance     |     Version:
 Severity:  normal          |  Resolution:
 Keywords:  needs-patch     |
----------------------------+------------------

Comment (by nacin):

 If we pass $this->posts[0]->ID instead of the $this->posts[0] object to
 get_post_status(), the extra query will be avoided. (The
 _get_post_ancestors() call is caused by an object with empty(filter)
 getting into get_post(). The lack of a query is caused by an ID getting
 into get_post() for a post object that is already cached.)

 This avoids the unnecessary ancestors query, at least until
 get_post_ancestors() gets called.

 However, subsequent calls to get_post_ancestors() will result in
 subsequent queries for the same data, as get_post_status() is no longer
 putting ancestors into the cache. Perhaps we need to call
 _get_post_ancestors() for is_singular(), as that's what was happening
 already with 3.3, and that's where ancestors are most likely to be used.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/18536#comment:82>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list