MDL-34933 core_message: Adding index to improve database access on message_working...
authorMike Churchward <mike@remote-learner.net>
Wed, 17 Apr 2013 14:18:55 +0000 (10:18 -0400)
committerMike Churchward <mike@remote-learner.net>
Mon, 22 Apr 2013 12:35:44 +0000 (08:35 -0400)
lib/db/install.xml
lib/db/upgrade.php
version.php

index 22835b2..1fc7e86 100644 (file)
       <KEYS>
         <KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="primary key of the table, please edit me"/>
       </KEYS>
       <KEYS>
         <KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="primary key of the table, please edit me"/>
       </KEYS>
+      <INDEXES>
+        <INDEX NAME="unreadmessageid_idx" UNIQUE="false" FIELDS="unreadmessageid" COMMENT="Index on unreadmessage id"/>
+      </INDEXES>
     </TABLE>
     <TABLE NAME="files" COMMENT="description of files, content is stored in sha1 file pool" PREVIOUS="message_working" NEXT="files_reference">
       <FIELDS>
     </TABLE>
     <TABLE NAME="files" COMMENT="description of files, content is stored in sha1 file pool" PREVIOUS="message_working" NEXT="files_reference">
       <FIELDS>
index 6233a52..48bf758 100644 (file)
@@ -1142,5 +1142,19 @@ function xmldb_main_upgrade($oldversion) {
         upgrade_main_savepoint(true, 2012062506.02);
     }
 
         upgrade_main_savepoint(true, 2012062506.02);
     }
 
+    if ($oldversion < 2012062506.06) {
+        // Adding index to unreadmessageid field of message_working table (MDL-34933)
+        $table = new xmldb_table('message_working');
+        $index = new xmldb_index('unreadmessageid_idx', XMLDB_INDEX_NOTUNIQUE, array('unreadmessageid'));
+
+        // Conditionally launch add index unreadmessageid
+        if (!$dbman->index_exists($table, $index)) {
+            $dbman->add_index($table, $index);
+        }
+        
+        // Main savepoint reached.
+        upgrade_main_savepoint(true, 2012062506.06);
+    }
+
     return true;
 }
     return true;
 }
index 9f8242f..7a31246 100644 (file)
@@ -30,7 +30,7 @@
 defined('MOODLE_INTERNAL') || die();
 
 
 defined('MOODLE_INTERNAL') || die();
 
 
-$version  = 2012062506.05;              // YYYYMMDD      = weekly release date of this DEV branch
+$version  = 2012062506.06;              // YYYYMMDD      = weekly release date of this DEV branch
                                         //         RR    = release increments - 00 in DEV branches
                                         //           .XX = incremental changes
 
                                         //         RR    = release increments - 00 in DEV branches
                                         //           .XX = incremental changes