Make WordPress Core

Opened 7 years ago

Last modified 2 weeks ago

#43818 new enhancement

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

Reported by: flixos90's profile flixos90 Owned by:
Milestone: Future Release 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 (3)

This ticket was mentioned in Slack in #core-performance by swissspidy. View the logs.


2 months ago

#2 @swissspidy
2 months ago

@flixos90 After all this time, is this one still relevant?

#3 @flixos90
2 weeks ago

  • Milestone changed from Awaiting Review to Future Release

@swissspidy I think it is, ideally it just needs feedback on the proposed approach.

Since nobody has objected so far, maybe an alternative good next step would be to implement a pull request.

I don't have capacity for this at the moment, but will take a note. If someone else is interested in implementing a pull request for this, please go ahead - much appreciated!

Note: See TracTickets for help on using tickets.