Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
i18n_menu_menu_link_update() currently makes the menu_rebuild() operation (that is quite an expensive operation itself) about 17% slower.
So a 30s menu_rebuild() turns into a 35s menu_rebuild().
+ It adds 2 to 3 queries for each menu item, for a 1,250 item rebuild, that is 2,500 queries.
There's at least 2 ways to improve this method:
1) Only add to the $fields array the language field if it is us changing it's value.
2) Compare the new menu_link to the previous one to only trigger i18n_string_object_update() or i18n_string_object_remove() if relevant changes have been made to the menu_item.
Comment | File | Size | Author |
---|---|---|---|
#9 | 2511696-slow-menu-rebuild.patch | 2.31 KB | david_garcia |
Comments
Comment #1
david_garcia CreditAttribution: david_garcia commentedComment #3
david_garcia CreditAttribution: david_garcia commentedI forgot to mention that for this to work core needs a small patch:
#2511704: Pass the previous menu_link $item when calling menu_link_insert/menu_link_update
Comment #4
david_garcia CreditAttribution: david_garcia commentedJust to make it compatible with current core and see if it passes tests. Without the patch in core no performance benefit.
Comment #5
david_garcia CreditAttribution: david_garcia commentedComment #6
david_garcia CreditAttribution: david_garcia commentedComment #7
david_garcia CreditAttribution: david_garcia commentedComment #8
david_garcia CreditAttribution: david_garcia commentedComment #9
david_garcia CreditAttribution: david_garcia commented