[wp-trac] [WordPress Trac] #40613: Add query cache to WP_User_Query class

WordPress Trac noreply at wordpress.org
Sun Apr 30 18:46:04 UTC 2017


#40613: Add query cache to WP_User_Query class
-----------------------------+------------------------------
 Reporter:  johnjamesjacoby  |       Owner:
     Type:  defect (bug)     |      Status:  new
 Priority:  normal           |   Milestone:  Awaiting Review
Component:  Users            |     Version:
 Severity:  normal           |  Resolution:
 Keywords:                   |     Focuses:  performance
-----------------------------+------------------------------
Description changed by johnjamesjacoby:

Old description:

> When calling `get_users()` the query itself is not cached. If multiple
> calls to `get_users()` with the same `$args` array occur, each will
> result in a database hit.
>
> Note that each individual user object is cached, and that query caches
> will need to be invalidated when users are added/removed/edited.
>
> Theoretically, on busy sites with many users who are constantly changing
> passwords and things, caching user queries may not yield a significant
> performance improvement. For the majority of installations (where users
> are not shifted around nearly as much) this could be result in several
> additional cache hits per page load (especially with persistent caches in
> place.)
>
> Patch imminent.

New description:

 When calling `get_users()` the query itself is not cached. If multiple
 calls to `get_users()` with the same `$args` array occur, each will result
 in a database hit.

 Note that each individual user object is cached, and that query caches
 will need to be invalidated when users are added/removed/edited.

 Theoretically, on busy sites with many users who are constantly changing
 passwords and things, caching user queries may not yield a significant
 performance improvement. For the majority of installations (where users
 are not shifted around nearly as much) this could result in several
 additional cache hits per page load (especially with persistent caches in
 place.)

 Functions like `wp_dropdown_users()` are called multiple times when
 viewing the Posts list-table, and many plugins also call `get_users()`
 knowing that user objects are cached (but not noticing the additional
 database hits for each call itself.)

 Membership plugins like BuddyPress would have inherent benefits, and
 bbPress could operate more efficiently when querying for the intersection
 of many topics with many users who are engaged in them.

 Patch imminent.

--

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


More information about the wp-trac mailing list