MDL-50805 Messages: Add index to message_read to speed up message crons
authorPau Ferrer Ocaña <crazyserver@gmail.com>
Wed, 23 Sep 2015 15:02:39 +0000 (17:02 +0200)
committerPau Ferrer Ocaña <crazyserver@gmail.com>
Thu, 1 Oct 2015 08:34:30 +0000 (10:34 +0200)
lib/db/install.xml
lib/db/upgrade.php
version.php

index 9a0f927..de8750a 100644 (file)
       <INDEXES>
         <INDEX NAME="useridto" UNIQUE="false" FIELDS="useridto"/>
         <INDEX NAME="useridfromtodeleted" UNIQUE="false" FIELDS="useridfrom, useridto, timeuserfromdeleted, timeusertodeleted"/>
+        <INDEX NAME="notificationtimeread" UNIQUE="false" FIELDS="notification, timeread"/>
       </INDEXES>
     </TABLE>
     <TABLE NAME="message_contacts" COMMENT="Maintains lists of relationships between users">
index fd98221..d102756 100644 (file)
@@ -4572,5 +4572,20 @@ function xmldb_main_upgrade($oldversion) {
         upgrade_main_savepoint(true, 2015092200.00);
     }
 
+    if ($oldversion < 2015100100.00) {
+
+        // Define index notification (not unique) to be added to message_read.
+        $table = new xmldb_table('message_read');
+        $index = new xmldb_index('notificationtimeread', XMLDB_INDEX_NOTUNIQUE, array('notification', 'timeread'));
+
+        // Conditionally launch add index notification.
+        if (!$dbman->index_exists($table, $index)) {
+            $dbman->add_index($table, $index);
+        }
+
+        // Main savepoint reached.
+        upgrade_main_savepoint(true, 2015100100.00);
+    }
+
     return true;
 }
index 19abbe4..83cda25 100644 (file)
@@ -29,7 +29,7 @@
 
 defined('MOODLE_INTERNAL') || die();
 
-$version  = 2015092400.00;              // YYYYMMDD      = weekly release date of this DEV branch.
+$version  = 2015100100.00;              // YYYYMMDD      = weekly release date of this DEV branch.
                                         //         RR    = release increments - 00 in DEV branches.
                                         //           .XX = incremental changes.