#55372 closed enhancement (fixed)
Use tax_query in wp_get_nav_menu_items
Reported by: | spacedmonkey | Owned by: | spacedmonkey |
---|---|---|---|
Milestone: | 6.0 | Priority: | normal |
Severity: | normal | Version: | 3.0 |
Component: | Menus | Keywords: | has-patch needs-unit-tests good-first-bug has-dev-note |
Focuses: | performance | Cc: |
Description
Remove usage of get_objects_in_term
and replace with a tax_query. This adds a level of consistency and will improve caching.
Attachments (7)
Change History (19)
This ticket was mentioned in PR #2399 on WordPress/wordpress-develop by spacedmonkey.
3 years ago
#2
Trac ticket: https://core.trac.wordpress.org/ticket/55372
#3
@
3 years ago
I would love the thoughts on @boonebgorges on this one.
Basically, it makes more sense to use taxonomy query check. Tax queries are cached now and performance of them is pretty solid. Long term, I would like deprecate get_objects_in_term
, as it is only used in two place ( one them is here ).
#5
@
3 years ago
After some more testing with a menu with 200 items in it, I found some interesting results.
Currently, there is one query to get all the object ids and another to get post objects ( menu items ). In my test, with a menu with 200 items, this resulted to two queries returning 200 rows. The post query, results in an extremely long query with 200 ids in an IN state in the query.
Replacing with a taxonomy query, means one single request. I will admit, this query is a little slower that the original WP_Query. But as you are replace two queries with one, it there is still a net performance win. Not to mention less stress on the database, not returning 200 rows in two queries.
#6
@
3 years ago
I logged some notes on the pull request using a testing plugin to loop through some various sized menus using the old and the new code.
I was seeing the longer query @spacedmonkey documents above but the cumulative result of the patch was a positive.
It would be good to get some feedback from hosts with separate web and MySQL servers to make sure that's not a problem.
Generally, I'm in favour of this going in.
This ticket was mentioned in Slack in #hosting-community by spacedmonkey. View the logs.
3 years ago
#8
@
3 years ago
- Milestone changed from Awaiting Review to 6.0
- Owner set to spacedmonkey
- Status changed from new to assigned
spacedmonkey commented on PR #2399:
3 years ago
#10
Committed
Created a PR #2399