[wp-trac] [WordPress Trac] #36953: Meta lazyloading can cause excessive calls to object cache

WordPress Trac noreply at wordpress.org
Thu May 26 16:36:36 UTC 2016


#36953: Meta lazyloading can cause excessive calls to object cache
--------------------------+-----------------
 Reporter:  boonebgorges  |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  4.6
Component:  Query         |    Version:
 Severity:  normal        |   Keywords:
  Focuses:  performance   |
--------------------------+-----------------
 `WP_Query` calls `wp_queue_posts_for_term_meta_lazyload()`, which in turn
 grabs the `{$taxonomy}_relationships` cache for each found post, for each
 taxonomy that they belong to. So if you're fetching 20 items, and each
 item is in 10 taxonomies, the process will require 200 cache gets. This is
 in addition to the dozens of other other cache priming gets that happens
 in `WP_Query`.

 On very high traffic sites running an object cache backend, the high
 volume calls to the cache can cause performance issues.

 A truly general fix would be `wp_cache_get_multi()`, which would allow
 functions like this to reduce cache roundtrips by one or two orders of
 magnitude. See #20875.

 In the meantime, two things to explore:
 1. `WP_Query` decides whether to queue posts for termmeta lazyloading
 based on the value of 'update_term_meta_cache'. This should be more fine-
 grained. A new `WP_Query` parameter `lazyload_term_meta`, which would
 default to the value of `update_term_meta`, seems appropriate. This way,
 very high-traffic sites that don't use termmeta and thus don't need to
 lazyload it can disable the feature in a targeted way, via a
 `pre_get_posts` callback.
 2. Look for ways to cut back on cache queries in the lazyload process. Not
 sure if that's feasible, since different posts keep their taxonomy
 relationships in different cache buckets, but it's worth looking into.

 1 should be doable for 4.6.

 cc @patrickgarman, who brought this to my attention.

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


More information about the wp-trac mailing list