From 88884f89c11d27a29fe85d9debeef1f430e12f59 Mon Sep 17 00:00:00 2001
From: Angie Byron <webchick@24967.no-reply.drupal.org>
Date: Sun, 9 Aug 2009 02:46:27 +0000
Subject: [PATCH] #289504 by mikeryan and moshe weitzman: Add index on comment,
 uid columns to speed up user_delete().

---
 modules/comment/comment.install | 38 ++++++++++++++++++++++-----------
 1 file changed, 26 insertions(+), 12 deletions(-)

diff --git a/modules/comment/comment.install b/modules/comment/comment.install
index 61ca2d14aa15..7257930995a8 100644
--- a/modules/comment/comment.install
+++ b/modules/comment/comment.install
@@ -137,6 +137,28 @@ function comment_update_7004() {
   return array();
 }
 
+/**
+ * Create comment Field API bundles.
+ */
+function comment_update_7005() {
+  $ret = array();
+
+  foreach (node_type_get_types() as $info) {
+    field_attach_create_bundle('comment_node_' . $info->type);
+  }
+  return $ret;
+}
+
+/**
+ * Create user related indexes.
+ */
+function comment_update_7006() {
+  $ret = array();
+  db_add_index($ret, 'comment', 'comment_uid', array('uid'));
+  db_add_index($ret, 'node_comment_statistics', 'last_comment_uid', array('last_comment_uid'));
+  return $ret;
+}
+
 /**
  * @} End of "defgroup updates-6.x-to-7.x"
  * The next series of updates should start at 8000.
@@ -241,10 +263,12 @@ function comment_schema() {
     'indexes' => array(
       'comment_status_pid' => array('pid', 'status'),
       'comment_num_new' => array('nid', 'timestamp', 'status'),
+      'comment_uid' => array('uid'),
     ),
     'primary key' => array('cid'),
     'foreign keys' => array(
       'nid' => array('node' => 'nid'),
+      'uid' => array('users' => 'uid'),
     ),
   );
 
@@ -288,23 +312,13 @@ function comment_schema() {
     'indexes' => array(
       'node_comment_timestamp' => array('last_comment_timestamp'),
       'comment_count' => array('comment_count'),
+      'last_comment_uid' => array('last_comment_uid'),
     ),
     'foreign keys' => array(
       'nid' => array('node' => 'nid'),
+      'last_comment_uid' => array('users' => 'uid'),
     ),
   );
 
   return $schema;
-}
-
-/**
- * Create comment Field API bundles.
- */
-function comment_update_7005() {
-  $ret = array();
-
-  foreach (node_type_get_types() as $info) {
-    field_attach_create_bundle('comment_node_' . $info->type);
-  }
-  return $ret;
 }
\ No newline at end of file
-- 
GitLab