Add comment_date_gmt key to comments table. Optimize _wp_get_comment_list() query. fixes #5785

git-svn-id: http://svn.automattic.com/wordpress/trunk@6825 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-02-13 19:15:30 +00:00
parent e5879ea923
commit 8bbf359295
3 changed files with 6 additions and 5 deletions

View File

@ -53,7 +53,8 @@ CREATE TABLE $wpdb->comments (
PRIMARY KEY (comment_ID),
KEY comment_approved (comment_approved),
KEY comment_post_ID (comment_post_ID),
KEY comment_approved_date_gmt (comment_approved,comment_date_gmt)
KEY comment_approved_date_gmt (comment_approved,comment_date_gmt),
KEY comment_date_gmt (comment_date_gmt)
) $charset_collate;
CREATE TABLE $wpdb->links (
link_id bigint(20) NOT NULL auto_increment,

View File

@ -556,9 +556,9 @@ function _wp_get_comment_list( $s = false, $start, $num ) {
comment_author_IP LIKE ('%$s%') OR
comment_content LIKE ('%$s%') ) AND
comment_approved != 'spam'
ORDER BY comment_date DESC LIMIT $start, $num");
ORDER BY comment_date_gmt DESC LIMIT $start, $num");
} else {
$comments = $wpdb->get_results( "SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->comments WHERE comment_approved = '0' OR comment_approved = '1' ORDER BY comment_date DESC LIMIT $start, $num" );
$comments = $wpdb->get_results( "SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->comments USE INDEX (comment_date_gmt) WHERE comment_approved = '0' OR comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT $start, $num" );
}
update_comment_cache($comments);

View File

@ -16,6 +16,6 @@ $wp_version = '2.4-bleeding';
*
* @global int $wp_db_version
*/
$wp_db_version = 6748;
$wp_db_version = 6825;
?>
?>