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

WordPress Trac wp-trac at lists.automattic.com
Fri Mar 9 19:35:55 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 ryan):

 In 3.3 WP_Query::get_posts(), get_post_status() called get_post() called
 _get_post_ancestors() before the caches were primed.  This meant a post
 object with ancestors made it into the cache. In 3.4, the caches are
 primed without ancestors before get_post_status() -> get_post() ->
 _get_post_ancestors() is called. Since get_post() does cache adds, not
 sets, the first add without the ancestors wins. We could fix this by doing
 a cache set in get_post() if the ancestors property is not set in the
 cached version. I'd rather not mess with that right now, however. A
 simpler alternative that should suffice for the time being is to call
 _get_post_ancestors() from get_post_ancestors() if the ancestors property
 is not set. This could result in the query being run on every
 _get_post_ancestors() call in the situation where the cached object does
 not have ancestors, but I can live with that. In 3.5 we can contemplate a
 proper WP_Post object with lazy ancestors fetching and improved caching.

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


More information about the wp-trac mailing list