[wp-trac] [WordPress Trac] #41714: wp_list_pages() - horrible performance due to eventual "SELECT *"

WordPress Trac noreply at wordpress.org
Wed May 15 23:05:01 UTC 2019


#41714: wp_list_pages() - horrible performance due to eventual "SELECT *"
-------------------------------+------------------------------
 Reporter:  DavidAnderson      |       Owner:  (none)
     Type:  defect (bug)       |      Status:  new
 Priority:  normal             |   Milestone:  Awaiting Review
Component:  Posts, Post Types  |     Version:  4.9
 Severity:  normal             |  Resolution:
 Keywords:  2nd-opinion        |     Focuses:
-------------------------------+------------------------------
Changes (by garrett-eclipse):

 * keywords:   => 2nd-opinion


Comment:

 Thanks @DavidAnderson for the report.

 Looking at the chain of function calls just wanted to clarify that
 `wp_list_pages()` calls `get_pages()` and not `get_posts()` as seen here;
 https://github.com/WordPress/WordPress/blob/df438d90a0d8affaaded8177ad96986cacf83994
 /wp-includes/post-template.php#L1311

 If it was calling `get_posts()` then it could simply use the 'fields'
 argument in the `$args` array, but that's not the case.

 Looking at core probably the best approach here would be updating
 `get_posts()` to support a `fields` argument similar to what's used in
 `get_posts()` as get_posts simply uses WP_Query. If get_pages was updated
 to also use WP_Query then it would by default support the 'fields'
 parameter as well which is documented here;
 https://codex.wordpress.org/Class_Reference/WP_Query#Return_Fields_Parameter

 The get_pages function is drastically different than get_posts and has
 caching and a direct SQL Select call made. It would be nice to make them
 consistent but would be a large effort to ensure back-compat.

 "Note that, although similar to get_posts(), several of the parameter
 names and values differ. (It is implemented quite differently, see
 get_posts().)"
 Reference - https://codex.wordpress.org/Function_Reference/get_pages

 If it's determined that making them consistent and using WP_Query is an
 overwhelming effort than potentially introducing 'fields' to the get_pages
 arguments may be an easier approach as it could then be used directly in
 the SQL statement.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/41714#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list