[wp-trac] [WordPress Trac] #18369: Pre-cache post_meta for nav_menu_items rather than querying one at a time
WordPress Trac
wp-trac at lists.automattic.com
Wed Aug 10 15:25:27 UTC 2011
#18369: Pre-cache post_meta for nav_menu_items rather than querying one at a time
-----------------------------+-----------------------------
Reporter: mitchoyoshitaka | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Performance | Version:
Severity: minor | Keywords: has-patch
-----------------------------+-----------------------------
We know that `wp_get_nav_menu_items` is going to have to `get_post_meta`
on each individual nav menu item, and unless it's already cached, each of
these `get_post_meta` will spawn their own database query to
`update_meta_cache`.
Instead, we could `update_meta_cache` once on all of the objects which we
know we're going to hit at the beginning of `wp_get_nav_menu_items`.
Here's the effect of this patch on DB queries on a site I'm working on,
with two decently sized nav menus: (averaged over 10 hits)
3.3-trunk: 69 ms, 198 queries
with patch: 55 ms, 142 queries
--
Ticket URL: <http://core.trac.wordpress.org/ticket/18369>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list