[wp-trac] [WordPress Trac] #35454: `lazyload_term_meta` is called many time when calling `get_term_metadata`
WordPress Trac
noreply at wordpress.org
Fri Jan 15 20:50:18 UTC 2016
#35454: `lazyload_term_meta` is called many time when calling `get_term_metadata`
--------------------------+------------------------------
Reporter: sfai05 | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: 4.4
Severity: normal | Resolution:
Keywords: | Focuses: performance
--------------------------+------------------------------
Comment (by boonebgorges):
@sfai05 - Thanks for the details.
I'm struggling to see whether this is a fundamental architectural problem
with the lazyloading technique, or whether there's a race condition that's
causing many more cache checks than is required. Maybe you can help me
figure this out.
`WP_Query::lazyload_term_meta()` is designed to bail when
`$this->updated_term_meta_cache` is true. However, this flag doesn't get
set until the end of the method. I wonder if this fact, combined with lots
of calls to `get_term_meta()`, is causing `get_object_term_cache()` to be
called more often than it should. Two things to look at:
* How many times is `lazyload_term_meta()` being called? (It should be
once for every call to `get_term_meta()`.) And how many times is it
getting past the `$this->update_term_meta_cache` flag? (It should be once
for each `WP_Query` loop previously loaded on the page.)
* If you move the `$this->updated_term_meta_cache = true` check to the top
of the method - just before the `// We can only lazyload...` comment -
does it help?
--
Ticket URL: <https://core.trac.wordpress.org/ticket/35454#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list