[wp-trac] [WordPress Trac] #39090: Remove duplicate query from posts page in the admin
WordPress Trac
noreply at wordpress.org
Mon Dec 5 20:33:20 UTC 2016
#39090: Remove duplicate query from posts page in the admin
-----------------------------------------+-----------------------------
Reporter: rodrigosprimo | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Posts, Post Types | Version:
Severity: normal | Keywords:
Focuses: administration, performance |
-----------------------------------------+-----------------------------
The posts page in the admin (`/wp-admin/edit.php`) is running twice the
query below. This is a problem specially for sites with a significant
number of users since this query can be super slow (see #19867 and
#28160).
{{{#!php
SELECT wp_users.ID,wp_users.user_login,wp_users.display_name
FROM wp_users
INNER JOIN wp_usermeta
ON ( wp_users.ID = wp_usermeta.user_id )
WHERE 1=1
AND ( ( wp_usermeta.meta_key = 'wp_user_level'
AND wp_usermeta.meta_value != '0' ) )
ORDER BY display_name ASC
}}}
The query is executed by `WP_User_Query::query()` and, in this particular
page, is called by the function `wp_dropdown_users()`.
The attached patch fixes this problem by adding the result to the cache
when the query is run the first time. Preventing multiple executions of
the same query.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/39090>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list