From 00a51457f4fe4195c4a3b2ffaacc0e9fc5b609e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Wed, 23 Sep 2015 17:02:39 +0200 Subject: [PATCH] MDL-50805 Messages: Add index to message_read to speed up message crons --- lib/db/install.xml | 1 + lib/db/upgrade.php | 15 +++++++++++++++ version.php | 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/db/install.xml b/lib/db/install.xml index fcc226d84d2..7c8e07d61e2 100644 --- a/lib/db/install.xml +++ b/lib/db/install.xml @@ -565,6 +565,7 @@ + diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index 319524d3ac0..79fba742023 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -4455,5 +4455,20 @@ function xmldb_main_upgrade($oldversion) { upgrade_main_savepoint(true, 2015051101.07); } + if ($oldversion < 2015051102.03) { + + // 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, 2015051102.03); + } + return true; } diff --git a/version.php b/version.php index 7d31941a332..83216e37435 100644 --- a/version.php +++ b/version.php @@ -29,7 +29,7 @@ defined('MOODLE_INTERNAL') || die(); -$version = 2015051102.02; // 20150511 = branching date YYYYMMDD - do not modify! +$version = 2015051102.03; // 20150511 = branching date YYYYMMDD - do not modify! // RR = release increments - 00 in DEV branches. // .XX = incremental changes.