From be7a01b355afec9999ee4f3ddd58ddf2914cc66c Mon Sep 17 00:00:00 2001 From: Eric Merrill Date: Thu, 11 Feb 2016 12:30:01 -0500 Subject: [PATCH] MDL-53176 grades: Adding index to improve history search Backport of MDL-50385 --- 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 7c8e07d61e2..62420d6832f 100644 --- a/lib/db/install.xml +++ b/lib/db/install.xml @@ -1918,6 +1918,7 @@ + diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index 0e238297217..d8f98b95c20 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -4488,5 +4488,22 @@ function xmldb_main_upgrade($oldversion) { upgrade_main_savepoint(true, 2015051104.07); } + if ($oldversion < 2015051104.12) { + // 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, 2015051104.09); + } + return true; } diff --git a/version.php b/version.php index 3cf004da942..44ccff03511 100644 --- a/version.php +++ b/version.php @@ -29,7 +29,7 @@ defined('MOODLE_INTERNAL') || die(); -$version = 2015051104.11; // 20150511 = branching date YYYYMMDD - do not modify! +$version = 2015051104.12; // 20150511 = branching date YYYYMMDD - do not modify! // RR = release increments - 00 in DEV branches. // .XX = incremental changes.