WordPress.org

Make WordPress Core

Opened 5 weeks ago

#43818 new enhancement

Invalidate query caches less aggressively by using a `last_changed` key specific to metadata

Reported by: flixos90 Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Options, Meta APIs Keywords: needs-patch needs-unit-tests
Focuses: multisite, performance Cc:

Description

Currently, the meta implementations for posts, terms, comments and sites (in multisite) invalidate all respective query caches when any value is changed (via setting the last_changed key). This is a really aggressive method of cache invalidation and causes in query caches being too frequently invalidated, resulting in lots of unnecessary cache misses.

Most queries (or at least many queries) do not make use of meta queries, and those should stay unaffected by when a meta value changes. Therefore I suggest introducing a specific meta_last_changed cache key, and have the meta functions set that one instead of the generic last_changed. In the query classes, we can then check if a meta query is present, and only then make use of the meta_last_changed key - otherwise we can ignore it and use the regular last_changed key.

Regarding the initial implementation, we should think about whether we would wanna roll this out to all the above object types immediately, or whether we should rather start with an object type less popular for metadata (i.e. not posts). Related to this is #43813.

Change History (0)

Note: See TracTickets for help on using tickets.