[wp-trac] [WordPress Trac] #20323: update_post_caches causes time-out on large queries if cache_results flag not set

WordPress Trac wp-trac at lists.automattic.com
Thu Mar 29 12:25:57 UTC 2012


#20323: update_post_caches causes time-out on large queries if cache_results flag
not set
--------------------------+-----------------------------
 Reporter:  bytesmasher   |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Query         |    Version:  3.3.1
 Severity:  normal        |   Keywords:
--------------------------+-----------------------------
 I ran into this problem when debugging why the Advanced Custom Fields
 plugin's option screen was timing out on my site. I have over 8000 items
 in my wp_posts table, and the plugin pulls back every post to populate a
 dropdown (I plan on bringing up this issue with the plugin author)

 I was relieved to find out that it wasn't actually the query that was
 choking, (for a moment I thought mysql was horribly misconfigured) but
 actually the update_post_caches function.

 I realize that the cache_results flag was added to avoid this issue, but
 it occurs to me that many plugin developers will not foresee sites with as
 much content as mine.

 My suggestion is this: Place a "cache_threshold" option in the Wordpress
 settings... make the default something reasonable like 20 (or maybe even
 ignore this option all together and grab the value from the posts_per_page
 option, as set on the admin screen.. it's important it come from the admin
 screen and not the query options because in the case I encountered it, the
 posts per page option in the query was set to -1). If the cache_results
 flag is not set, check after the initial database query is completed to
 grab the number of returned posts... if it's more than the
 cache_threshold, then don't call update_post_caches.

 This will increase the stability of the core, and prevent plugins from
 accidentally breaking things with unreasonable queries on large sites.

 Sorry if anything in this ticket doesn't make sense... it's early and I
 haven't had my coffee yet.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/20323>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list