From 5c33a003d8523ccec7dfd8dc8a506e774bf347b8 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Mon, 26 Jan 2009 22:34:50 +0000 Subject: [PATCH] Force the index only for 0 OR 1 queries. see #7415 git-svn-id: https://develop.svn.wordpress.org/trunk@10446 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/includes/template.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php index 8b4a4231ee..590f0c75bc 100644 --- a/wp-admin/includes/template.php +++ b/wp-admin/includes/template.php @@ -1921,7 +1921,8 @@ function _wp_get_comment_list( $status = '', $s = false, $start, $num, $post = 0 $num = (int) $num; $post = (int) $post; $count = wp_count_comments(); - + $index = ''; + if ( 'moderated' == $status ) { $approved = "comment_approved = '0'"; $total = $count->moderated; @@ -1934,6 +1935,7 @@ function _wp_get_comment_list( $status = '', $s = false, $start, $num, $post = 0 } else { $approved = "( comment_approved = '0' OR comment_approved = '1' )"; $total = $count->moderated + $count->approved; + $index = 'USE INDEX (comment_date_gmt)'; } if ( $post ) { @@ -1971,7 +1973,7 @@ function _wp_get_comment_list( $status = '', $s = false, $start, $num, $post = 0 $approved $typesql"; } else { - $query = "FROM $wpdb->comments USE INDEX (comment_date_gmt) WHERE $approved $post $typesql"; + $query = "FROM $wpdb->comments $index WHERE $approved $post $typesql"; } $comments = $wpdb->get_results("SELECT * $query $orderby");