[wp-trac] [WordPress Trac] #55372: Use tax_query in wp_get_nav_menu_items

WordPress Trac noreply at wordpress.org
Tue Mar 22 22:50:45 UTC 2022

#55372: Use tax_query in wp_get_nav_menu_items
 Reporter:  spacedmonkey                         |       Owner:  (none)
     Type:  enhancement                          |      Status:  new
 Priority:  normal                               |   Milestone:  Awaiting
                                                 |  Review
Component:  Menus                                |     Version:  3.0
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch needs-unit-tests good-     |     Focuses:
  first-bug                                      |  performance

Comment (by spacedmonkey):

 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

Ticket URL: <https://core.trac.wordpress.org/ticket/55372#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform

More information about the wp-trac mailing list