WordPress.org

Make WordPress Core

Opened 2 years ago

Closed 8 months ago

#20323 closed defect (bug) (invalid)

update_post_caches causes time-out on large queries if cache_results flag not set

Reported by: bytesmasher Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.3.1
Component: Query Keywords: reporter-feedback
Focuses: Cc:

Description

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.

Change History (2)

comment:1 wonderboymusic18 months ago

  • Keywords reporter-feedback added

There have been performance improvements made for clean_post_cache() in 3.5. Can you run your code against trunk or supply example code to reproduce your issue?

comment:2 wonderboymusic8 months ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

No feedback from reporter in 9 months - reopen if this is still a thing.

Note: See TracTickets for help on using tickets.