[wp-trac] [WordPress Trac] #58001: Lazy load user capabilities in WP_User object
WordPress Trac
noreply at wordpress.org
Tue Mar 28 14:59:03 UTC 2023
#58001: Lazy load user capabilities in WP_User object
------------------------------------+-----------------------------
Reporter: spacedmonkey | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Users | Version:
Severity: normal | Keywords:
Focuses: multisite, performance |
------------------------------------+-----------------------------
WP_User object are used throughout WordPress and are loaded on the front
end [https://github.com/WordPress/wordpress-
develop/blob/907eb2893f331f5d9cda1f277d3dd3137deb0f50/src/wp-includes
/class-wp-query.php#L4715 in WP_Query]. This means creating a WP_User
object and this calls `for_site` method. This calls to user meta and
setups capability data. For a page with multiple users on it, this setup
of users, can be done multiple times. Loading user meta for all the users,
can be a problem, as this can be a lot of rows of data. For example, this
can result in 150 rows being loaded from the database for just 10 users.
For multisites or sites that have plugins that are heavy users of user
meta, that number can get much higher.
User meta is only loaded along with users, as it is needed for capability
data. To improve performance, find someway to lazy load the capability
only when they are used and also lazily load user meta at the same time.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/58001>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list