#55428 closed enhancement (fixed)
Improve cache priming in wp_get_nav_menu_items
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 6.0 | Priority: | normal |
Severity: | normal | Version: | 3.0 |
Component: | Menus | Keywords: | has-patch has-dev-note |
Focuses: | performance | Cc: |
Description
In the wp_get_nav_menu_items
, there are calls to get_terms and get_posts to prime object caches. There are new and better functions calls, _prime_post_caches
and _prime_term_caches
to prime caches.
Change History (8)
This ticket was mentioned in PR #2437 on WordPress/wordpress-develop by spacedmonkey.
3 years ago
#1
- Keywords has-patch added
spacedmonkey commented on PR #2437:
3 years ago
#2
This PR has a number of benefits.
- For menus with multiple post types, multiple SQL requires and replaced with a simple query.
- For menus with multiple taxonomy terms, multiple SQL requires and replaced with a simple query.
- If posts / terms are already in memory, no query at all.
- Those using object caching, will have caches primed.
- Those that use object cache that support multiple gets, will get caches primed in one object cache call.
- One less call to get_post_meta
- Much simplier code
#3
@
3 years ago
- Milestone changed from Awaiting Review to 6.0
The PR bot missed my review. Linked for reference.
While testing the pull request, I discovered the current priming of the term cache misses and each term is queried individually. I've moved this to the 6.0 milestone as I think it warrants it for the potential performance boost.
Unit test notes:
- it would be good to make sure the caches continue to be hit during the fetching and rendering of menus. If tests currently exist, I suspect they are not testing a render, terms or both but this needs confirming.
Manual testing notes:
- REST API endpoint for FSE
spacedmonkey commented on PR #2437:
3 years ago
#6
Merged.
Note: See
TracTickets for help on using
tickets.
Trac ticket: https://core.trac.wordpress.org/ticket/55428