[wp-trac] [WordPress Trac] #43818: Invalidate query caches less aggressively by using a `last_changed` key specific to metadata

WordPress Trac noreply at wordpress.org
Fri Apr 20 08:13:55 UTC 2018


#43818: Invalidate query caches less aggressively by using a `last_changed` key
specific to metadata
--------------------------------+------------------------------------------
 Reporter:  flixos90            |      Owner:  (none)
     Type:  enhancement         |     Status:  new
 Priority:  normal              |  Milestone:  Awaiting Review
Component:  Options, Meta APIs  |    Version:
 Severity:  normal              |   Keywords:  needs-patch needs-unit-tests
  Focuses:  multisite,          |
  performance                   |
--------------------------------+------------------------------------------
 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.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/43818>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list