[wp-trac] [WordPress Trac] #37189: In wp_term_query on cache ids
WordPress Trac
noreply at wordpress.org
Thu Mar 10 10:56:24 UTC 2022
#37189: In wp_term_query on cache ids
-------------------------------------------------+-------------------------
Reporter: spacedmonkey | Owner:
| spacedmonkey
Type: enhancement | Status: closed
Priority: normal | Milestone: 6.0
Component: Taxonomy | Version: 4.6
Severity: normal | Resolution: fixed
Keywords: has-patch needs-testing has-unit- | Focuses:
tests commit | performance
-------------------------------------------------+-------------------------
Changes (by spacedmonkey):
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"52836" 52836]:
{{{
#!CommitTicketReference repository="" revision="52836"
Taxonomy: Only store term_ids and object_ids in `WP_Term_Query` query
caches.
The query cache currently implemented in `WP_Term_Query` caches the final
output of the query, depending on what fields are requested. This is
wasteful, as if a user requests `fields` => `all`, then an unlimited array
of `WP_Term` objects could be stored in the object cache. Instead of
storing the whole WP_Term object, this change only the term_id is stored.
To get an array the full WP_Term objects, the `_prime_term_caches`
function is called with an array of ids. In instances where a persistent
object cache is not in use, then this will result in another SQL query to
be run. After `_prime_term_caches` is called if this term is requested
again in the same page load, then it will already be loaded into memory.
If a user runs `WP_Term_Query` with the fields param set to
`all_with_object_id`, an array of objects containing both the term_id and
object_ids are stored in cache.
This change also improves the logic to load term meta caches. This change
ensures that term meta is always primed for all terms loaded in the term
query.
Props Spacedmonkey, boonebgorges, jbpaul17, peterwilsoncc, flixos90,
pbearne.
Fixes #37189.
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/37189#comment:25>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list