[wp-trac] [WordPress Trac] #41714: wp_list_pages() - horrible performance due to eventual "SELECT *"
WordPress Trac
noreply at wordpress.org
Thu Jul 6 14:29:05 UTC 2023
#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:
-------------------------------+------------------------------
Comment (by DavidAnderson):
@spacedmonkey I see no improvement.
I ran a script with this content:
```
define('WP_DEBUG', true);
require 'wp-load.php';
define('SAVEQUERIES', true);
echo $wp_version;
wp_list_pages();
var_dump($wpdb->queries);
```
Here's the output on WP 6.2.2:
{{{
6.2.2
array(1) {
[0] =>
array(5) {
[0] =>
string(126) "SELECT * FROM wp_posts WHERE (post_type = 'page' AND
post_status = 'publish') ORDER BY menu_order,wp_posts.post_title ASC"
[1] =>
double(0.00075888633728027)
[2] =>
string(24) "wp_list_pages, get_pages"
[3] =>
double(1688653138.0517)
[4] =>
array(0) {
}
}
}
}}}
Upgraded to the latest WP 6.3 nightly. The output is then:
{{{
6.3-beta3-56143
array(1) {
[0] =>
array(5) {
[0] =>
string(200) "
SELECT wp_posts.*
FROM wp_posts
WHERE 1=1 AND wp_posts.post_type = 'page' AND
((wp_posts.post_status = 'publish'))
ORDER BY wp_posts.menu_order ASC,
wp_posts.post_title ASC
"
[1] =>
double(0.0011658668518066)
[2] =>
string(85) "wp_list_pages, get_pages, WP_Query->__construct,
WP_Query->query, WP_Query->get_posts"
[3] =>
double(1688653365.4942)
[4] =>
array(0) {
}
}
}
}}}
So, the only thing that's changed is the trace through to the SQL query,
and inconsequential details of the query. The query itself is still
`SELECT * FROM` on the posts table, and the full load of `post_content`
for every page on the site is being fetched just to list the post titles
and links.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/41714#comment:9>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list