[wp-trac] [WordPress Trac] #45105: wp_list_authors() performance issue. Queries for user data on authors with no posts

WordPress Trac noreply at wordpress.org
Wed Oct 17 12:25:26 UTC 2018


#45105: wp_list_authors() performance issue. Queries for user data on authors with
no posts
--------------------------+-----------------------------
 Reporter:  billerickson  |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  trunk
 Severity:  normal        |   Keywords:
  Focuses:  performance   |
--------------------------+-----------------------------
 On a client site with a single author, 4 posts, and thousands of
 subscribers (a membership site), we were getting over 17,000 queries on a
 404 page that included the wp_list_authors() function:
 https://cl.ly/aa7ed29b1815

 To reproduce this issue:
 1. Install Query Monitor + Debug Bar
 2. Add wp_list_authors() to a page and note the number of queries
 3. Generate new users (wp user generate) and notice the increase in
 queries

 The key issue is the check for empty posts runs after get_userdata() is
 called, so a query for that user's metadata happens regardless of their
 post count.

 Moving the post count check above get_userdata() fixes the issue.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/45105>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list