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

git-svn-id: https://develop.svn.wordpress.org/trunk@6825 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2008-02-13 19:15:30 +00:00
parent 4fa20e078a
commit 8268af4077
3 changed files with 6 additions and 5 deletions

View File

@ -53,7 +53,8 @@ CREATE TABLE $wpdb->comments (
PRIMARY KEY (comment_ID), PRIMARY KEY (comment_ID),
KEY comment_approved (comment_approved), KEY comment_approved (comment_approved),
KEY comment_post_ID (comment_post_ID), 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; ) $charset_collate;
CREATE TABLE $wpdb->links ( CREATE TABLE $wpdb->links (
link_id bigint(20) NOT NULL auto_increment, 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_author_IP LIKE ('%$s%') OR
comment_content LIKE ('%$s%') ) AND comment_content LIKE ('%$s%') ) AND
comment_approved != 'spam' comment_approved != 'spam'
ORDER BY comment_date DESC LIMIT $start, $num"); ORDER BY comment_date_gmt DESC LIMIT $start, $num");
} else { } 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); update_comment_cache($comments);

View File

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