From 60b69e4d2f590854ac3f720f1dbeed824f5b47e1 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 9a0f927097c..de8750aa922 100644 --- a/lib/db/install.xml +++ b/lib/db/install.xml @@ -569,6 +569,7 @@ + diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index fd98221e183..d10275668e9 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -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; } diff --git a/version.php b/version.php index 19abbe40295..83cda256f62 100644 --- a/version.php +++ b/version.php @@ -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.