[wp-trac] [WordPress Trac] #23336: Sticky Posts lack sanity bounding. If used too much, can severely degrade performance.

WordPress Trac noreply at wordpress.org
Thu Jan 31 22:00:16 UTC 2013


#23336: Sticky Posts lack sanity bounding. If used too much, can severely degrade
performance.
--------------------------+------------------------------
 Reporter:  markjaquith   |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Query         |     Version:
 Severity:  normal        |  Resolution:
 Keywords:  has-patch     |
--------------------------+------------------------------
Changes (by iandunn):

 * cc: ian_dunn@… (added)
 * keywords:   => has-patch


Comment:

 I've attached a WRX with 5k sticky posts to make the speed problem obvious
 on local installs. For me, the front page loaded in 600 ms with none of
 the posts set to sticky, and 11 seconds with all of them sticky. I'm
 testing with a front-page.php that only calls get_header() and
 get_footer(), so only the main query is running.

 I've also attached a first attempt at a patch. It just truncates the
 $sticky_posts array in get_posts() right after they're pulled from the DB,
 so that only the first 100 make it into the query. With the patch applied,
 the page load time drops back down to under a second.

 I wrapped the 100 value in a new filter called "sticky_posts_query_limit".

 When I get some more time, I still want to dig through the code a bit more
 and see if there are other situations that need a similar modification, or
 if there are any unintended consequences to this approach. It at least
 passes the query unit tests, though.

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


More information about the wp-trac mailing list