[wp-trac] [WordPress Trac] #59188: WP_Posts_List_Table causes post, postmeta, and term caches to be primed for all pages in the DB on load
WordPress Trac
noreply at wordpress.org
Tue Oct 3 14:59:38 UTC 2023
#59188: WP_Posts_List_Table causes post, postmeta, and term caches to be primed for
all pages in the DB on load
-------------------------------------+-------------------------------------
Reporter: kevinfodness | Owner: spacedmonkey
Type: defect (bug) | Status: closed
Priority: normal | Milestone: 6.4
Component: Query | Version: 6.1
Severity: normal | Resolution: fixed
Keywords: has-patch dev-feedback | Focuses: administration,
has-unit-tests | performance
-------------------------------------+-------------------------------------
Changes (by spacedmonkey):
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"56763" 56763]:
{{{
#!CommitTicketReference repository="" revision="56763"
Query: Improve caching behavior for WP_Query when retrieving id=>parent
fields
In [53941], the addition of query caching to `WP_Query` brought about an
unintended issue when querying for fields equal to id=>parent.
Specifically, on websites with object caching enabled and a substantial
number of pages, the second run of this query triggered the
`_prime_post_caches` function for id=>parent. This led to the unnecessary
priming of post, meta, and term caches, even when only id and parent
information were requested.
This commit addresses this issue by introducing a new function,
`_prime_post_parents_caches`, which primes a dedicated cache for post
parents. This cache is primed during the initial query execution.
Subsequently, the `wp_cache_get_multiple` function is employed to retrieve
all post parent data in a single object cache request, optimizing
performance.
Additionally, this commit extends the coverage of existing unit tests to
ensure the reliability of the changes.
Props kevinfodness, joemcgill, peterwilsoncc, LinSoftware, thekt12,
spacedmonkey.
Fixes #59188
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/59188#comment:38>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list