From fa13bbbd58b65c6634535c28613975efaddd6827 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Tue, 5 Feb 2008 18:04:17 +0000 Subject: [PATCH] Add key on comment_approved,comment_date to speed up last comment modified queries. fixes #5773 git-svn-id: https://develop.svn.wordpress.org/trunk@6729 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/includes/schema.php | 3 ++- wp-includes/comment.php | 4 ++-- wp-includes/version.php | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/wp-admin/includes/schema.php b/wp-admin/includes/schema.php index b3557d0672..2244f34329 100644 --- a/wp-admin/includes/schema.php +++ b/wp-admin/includes/schema.php @@ -52,7 +52,8 @@ CREATE TABLE $wpdb->comments ( user_id bigint(20) NOT NULL default '0', PRIMARY KEY (comment_ID), KEY comment_approved (comment_approved), - KEY comment_post_ID (comment_post_ID) + KEY comment_post_ID (comment_post_ID), + KEY comment_approved_date (comment_approved,comment_date) ) $charset_collate; CREATE TABLE $wpdb->links ( link_id bigint(20) NOT NULL auto_increment, diff --git a/wp-includes/comment.php b/wp-includes/comment.php index 67b488a6d1..f55f58bea0 100644 --- a/wp-includes/comment.php +++ b/wp-includes/comment.php @@ -207,10 +207,10 @@ function get_lastcommentmodified($timezone = 'server') { switch ( strtolower($timezone)) { case 'gmt': - $lastcommentmodified = $wpdb->get_var("SELECT comment_date_gmt FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 1"); + $lastcommentmodified = $wpdb->get_var("SELECT comment_date_gmt FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date DESC LIMIT 1"); break; case 'blog': - $lastcommentmodified = $wpdb->get_var("SELECT comment_date FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 1"); + $lastcommentmodified = $wpdb->get_var("SELECT comment_date FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date DESC LIMIT 1"); break; case 'server': $lastcommentmodified = $wpdb->get_var($wpdb->prepare("SELECT DATE_ADD(comment_date_gmt, INTERVAL %s SECOND) FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 1", $add_seconds_server)); diff --git a/wp-includes/version.php b/wp-includes/version.php index 23e2d81028..6d981caf42 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 = 6689; +$wp_db_version = 6730; ?> \ No newline at end of file