From 201a90938ef8fec7b854165fadf9360d8c1d9b8a Mon Sep 17 00:00:00 2001 From: Eric Merrill Date: Thu, 11 Feb 2016 12:30:12 -0500 Subject: [PATCH] MDL-50385 grades: Adding index to improve history search --- lib/db/install.xml | 1 + lib/db/upgrade.php | 17 +++++++++++++++++ version.php | 2 +- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/db/install.xml b/lib/db/install.xml index c8cda523452..b29a3f84417 100644 --- a/lib/db/install.xml +++ b/lib/db/install.xml @@ -1925,6 +1925,7 @@ + diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index 7e6ca5c4af0..c6be33cd05b 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -4916,5 +4916,22 @@ function xmldb_main_upgrade($oldversion) { upgrade_main_savepoint(true, 2016020201.00); } + if ($oldversion < 2016021100.01) { + // This could take a long time. Unfortunately, no way to know how long, and no way to do progress, so setting for 1 hour. + upgrade_set_timeout(3600); + + // Define index userid-itemid (not unique) to be added to grade_grades_history. + $table = new xmldb_table('grade_grades_history'); + $index = new xmldb_index('userid-itemid-timemodified', XMLDB_INDEX_NOTUNIQUE, array('userid', 'itemid', 'timemodified')); + + // Conditionally launch add index userid-itemid. + if (!$dbman->index_exists($table, $index)) { + $dbman->add_index($table, $index); + } + + // Main savepoint reached. + upgrade_main_savepoint(true, 2016021100.01); + } + return true; } diff --git a/version.php b/version.php index 6b769f9afd2..366dc18abe3 100644 --- a/version.php +++ b/version.php @@ -29,7 +29,7 @@ defined('MOODLE_INTERNAL') || die(); -$version = 2016021100.00; // YYYYMMDD = weekly release date of this DEV branch. +$version = 2016021100.01; // YYYYMMDD = weekly release date of this DEV branch. // RR = release increments - 00 in DEV branches. // .XX = incremental changes. -- 2.43.0