From 8268af4077d0bf194bf7c363a9766340a8624cdf Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Wed, 13 Feb 2008 19:15:30 +0000 Subject: [PATCH] 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 --- wp-admin/includes/schema.php | 3 ++- wp-admin/includes/template.php | 4 ++-- wp-includes/version.php | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/wp-admin/includes/schema.php b/wp-admin/includes/schema.php index a4815b740e..6ff1579751 100644 --- a/wp-admin/includes/schema.php +++ b/wp-admin/includes/schema.php @@ -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, diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php index b11e930895..f67b721c02 100644 --- a/wp-admin/includes/template.php +++ b/wp-admin/includes/template.php @@ -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); diff --git a/wp-includes/version.php b/wp-includes/version.php index ae40f61f0a..6d592939a2 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,6 +16,6 @@ $wp_version = '2.4-bleeding'; * * @global int $wp_db_version */ -$wp_db_version = 6748; +$wp_db_version = 6825; -?> \ No newline at end of file +?>