Opened 5 months ago
Last modified 4 months ago
#63945 new enhancement
Make cache in wp_count_posts persistent
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Future Release | Priority: | normal |
| Severity: | normal | Version: | 2.5 |
| Component: | Administration | Keywords: | has-patch |
| Focuses: | performance | Cc: |
Description
Current there is a cache in wp_count_posts function. See
$cache_key = _count_posts_cache_key( $type, $perm );
$counts = wp_cache_get( $cache_key, 'counts' );
As this use the counts cache group, this cache does not persistent between page requests. However the SQL query that is run in this function, can take a long time and can result in the admin list page to render slowly. This cache should be made to persistent.
Attachments (1)
Change History (7)
#1
@
5 months ago
- Summary changed from Make cache in wp_count_posts to Make cache in wp_count_posts persistent
This ticket was mentioned in PR #9793 on WordPress/wordpress-develop by jonnynews.
5 months ago
#2
- Keywords has-patch added
This ticket was mentioned in Slack in #core-performance by spacedmonkey. View the logs.
5 months ago
#5
@
5 months ago
See also: #35430 and ticket:47884#comment:8 - I note this seems to be using the route proposed there to allow caching.
I don't have any other feedback, other than that I dislike the query this generates so I'm all for adding caching :D
#6
@
4 months ago
@spacedmonkey Thanks for highlighting this issue.
I’m also experiencing similar slow rendering on large sites due to the non-persistent counts cache.
You can see an example of this behavior on https://nextreport.id
where the admin list page occasionally loads much slower than expected when the SQL query runs.
It would be great if this cache could be made persistent to avoid repeated heavy queries between page requests.
Make cache in wp_count_posts & wp_count_attachments persistent, by changing cache groups to
post-queriesand use the newwp_cache_get_saltedandwp_cache_set_saltedfunctions for cache invalidation.Trac ticket: https://core.trac.wordpress.org/ticket/63945