Index: wp-includes/comment.php
===================================================================
--- wp-includes/comment.php	(revision 19762)
+++ wp-includes/comment.php	(working copy)
@@ -914,27 +914,26 @@ function wp_count_comments( $post_id = 0 ) {
 	if ( false !== $count )
 		return $count;
 
-	$where = '';
+	$post_where = '';
 	if ( $post_id > 0 )
-		$where = $wpdb->prepare( "WHERE comment_post_ID = %d", $post_id );
-
-	$count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A );
+		$post_where = $wpdb->prepare( "comment_post_ID = %d", $post_id );
 
-	$total = 0;
 	$approved = array('0' => 'moderated', '1' => 'approved', 'spam' => 'spam', 'trash' => 'trash', 'post-trashed' => 'post-trashed');
-	foreach ( (array) $count as $row ) {
-		// Don't count post-trashed toward totals
-		if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] )
-			$total += $row['num_comments'];
-		if ( isset( $approved[$row['comment_approved']] ) )
-			$stats[$approved[$row['comment_approved']]] = $row['num_comments'];
-	}
 
-	$stats['total_comments'] = $total;
-	foreach ( $approved as $key ) {
-		if ( empty($stats[$key]) )
-			$stats[$key] = 0;
+	foreach ( $approved as $status => $label ) {
+		if ( 'approved' == $label )
+			continue; // We'll infer this later
+		$status_where = $wpdb->prepare( "comment_approved = %s", $status );
+		$where = "WHERE $status_where" . ( $post_where ? " AND $post_where" : '' );
+		$stats[$label] = (int) $wpdb->get_var( "SELECT COUNT( comment_ID ) FROM {$wpdb->comments} {$where}" );
 	}
+	// Grab the total
+	$total_where = empty( $post_where ) ? '' : "WHERE $post_where";
+	$stats['total_comments'] = (int) $wpdb->get_var( "SELECT count( comment_ID ) FROM {$wpdb->comments} {$total_where}" );
+	$stats['total_comments'] = $stats['total_comments'] - $stats['post-trashed']; // Don't count post-trashed towards total
+
+	// Now, infer 'approved', by subtracting moderated, spam and trash from total_comments (post-trashed was already removed)
+	$stats['approved'] = $stats['total_comments'] - $stats['moderated'] - $stats['spam'] - $stats['trash'];
 
 	$stats = (object) $stats;
 	wp_cache_set("comments-{$post_id}", $stats, 'counts');
