[wp-trac] [WordPress Trac] #19901: Speeding up Dashboard and Comment moderation SQL load
WordPress Trac
wp-trac at lists.automattic.com
Fri Jan 27 09:10:18 UTC 2012
#19901: Speeding up Dashboard and Comment moderation SQL load
-------------------------------------------------+-------------------------
Reporter: FolioVision | Owner:
Type: enhancement | markjaquith
Priority: normal | Status: accepted
Component: Performance | Milestone: 3.4
Severity: major | Version: 3.3.1
Keywords: has-patch 2nd-opinion needs-testing | Resolution:
-------------------------------------------------+-------------------------
Comment (by markjaquith):
We can also speed up comment queries in "count" mode (i.e. the mode where
it just returns the count) if we determine that the query type is one that
is handled by {{{wp_count_comments()}}}.
Example, within {{{WP_Comment_Query::query()}}}
{{{
if ( $count ) {
if ( $clauses['join'] == '' &&
$clauses['where'] == "( comment_approved =
'0' OR comment_approved = '1' )" &&
$clauses['limits'] == '' ) {
// We can return a much faster result for
this specific case (default view)
return wp_count_comments()->approved +
wp_count_comments()->moderated;
}
return $wpdb->get_var( $query );
}
}}}
That query can also take a few seconds with a large number of queries.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/19901#comment:11>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list