Opened 11 years ago
Closed 10 months ago
#25787 closed enhancement (wontfix)
wp_page_menu function is very inefficient
Reported by: | whawker | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | major | Version: | 3.7.1 |
Component: | Posts, Post Types | Keywords: | has-patch needs-testing |
Focuses: | template, performance | Cc: |
Description
I use wp_page_menu() to build my site's primary menu.
The MySQL query this creates, selects all the columns from the wp_posts table.
One of these columns is post_content. This means that when I create a menu, I am pulling massive amounts of data (the body text) from the DB which I will never (or very unlikely to) use. This adds a massive overhead which is killing my bandwidth.
Through my own investigations I have found that a menu can be built using only these columns from wp_posts
ID, menu_order, post_title, post_name, post_parent, post_type
This is much more efficient, but I do not feel I know the WordPress code base well enough to contribute to the core.
Attachments (2)
Change History (10)
#2
@
11 years ago
- Focuses performance added
- Keywords 2nd-opinion dev-feedback removed
- Milestone changed from Awaiting Review to Future Release
#3
@
10 years ago
I tried to extend the core functions without breaking the current functionality.
- wp_page_menu() has a new argument "optimize_query" which is delegated to wp_list_pages()
- wp_list_pages() has a new argument "optimize_query" which defines a minimum set of wp_posts columns (for get_pages()) to serve the function (if true)
- get_pages() has a new argument "restrict_columns" which restricts the number of of fetched columns from the database (if not empty)
Profiling with xdebug shows faster execution time and a dump of memory_get_peak_usage() shows lower memory consumption on my installation.
Related: #15459