mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-24 18:18:01 +01:00
Force the index only for 0 OR 1 queries. see #7415
git-svn-id: http://svn.automattic.com/wordpress/trunk@10446 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
00e9626be4
commit
2724b924d6
@ -1921,6 +1921,7 @@ function _wp_get_comment_list( $status = '', $s = false, $start, $num, $post = 0
|
|||||||
$num = (int) $num;
|
$num = (int) $num;
|
||||||
$post = (int) $post;
|
$post = (int) $post;
|
||||||
$count = wp_count_comments();
|
$count = wp_count_comments();
|
||||||
|
$index = '';
|
||||||
|
|
||||||
if ( 'moderated' == $status ) {
|
if ( 'moderated' == $status ) {
|
||||||
$approved = "comment_approved = '0'";
|
$approved = "comment_approved = '0'";
|
||||||
@ -1934,6 +1935,7 @@ function _wp_get_comment_list( $status = '', $s = false, $start, $num, $post = 0
|
|||||||
} else {
|
} else {
|
||||||
$approved = "( comment_approved = '0' OR comment_approved = '1' )";
|
$approved = "( comment_approved = '0' OR comment_approved = '1' )";
|
||||||
$total = $count->moderated + $count->approved;
|
$total = $count->moderated + $count->approved;
|
||||||
|
$index = 'USE INDEX (comment_date_gmt)';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $post ) {
|
if ( $post ) {
|
||||||
@ -1971,7 +1973,7 @@ function _wp_get_comment_list( $status = '', $s = false, $start, $num, $post = 0
|
|||||||
$approved
|
$approved
|
||||||
$typesql";
|
$typesql";
|
||||||
} else {
|
} 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");
|
$comments = $wpdb->get_results("SELECT * $query $orderby");
|
||||||
|
Loading…
Reference in New Issue
Block a user