[wp-trac] [WordPress Trac] #16846: wp_dashboard_recent_comments can generate hundreds of queries
WordPress Trac
wp-trac at lists.automattic.com
Tue Mar 15 18:09:47 UTC 2011
#16846: wp_dashboard_recent_comments can generate hundreds of queries
---------------------------------+-----------------------------
Reporter: ocean90 | Owner:
Type: defect (bug) | Status: new
Priority: high | Milestone: Future Release
Component: Comments | Version: 3.0
Severity: normal | Resolution:
Keywords: has-patch 3.2-early |
---------------------------------+-----------------------------
Comment (by azaozz):
The patch makes sense. When the displayed number of comments is less than
5 the inner `foreach` breaks but the `while` continues to run and fetches
more comments.
However there is some more room for optimization: looking at the next line
we check if the user can read the comment's post `current_user_can(
'read_post', $comment->comment_post_ID )`. Think we can safely bypass that
check for admin users (the most common case?) as they should be able to
read all posts. That would reduce the number of queries further.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/16846#comment:4>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list