Skip to content

Commit

Permalink
MDL-53176 grades: Adding index to improve history search
Browse files Browse the repository at this point in the history
Backport of MDL-50385
  • Loading branch information
ericmerrill committed Mar 10, 2016
1 parent 0fa77a0 commit be7a01b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/db/install.xml
Expand Up @@ -1918,6 +1918,7 @@
<INDEXES>
<INDEX NAME="action" UNIQUE="false" FIELDS="action" COMMENT="insert/update/delete"/>
<INDEX NAME="timemodified" UNIQUE="false" FIELDS="timemodified"/>
<INDEX NAME="userid-itemid-timemodified" UNIQUE="false" FIELDS="userid, itemid, timemodified" COMMENT="Improve history searching"/>
</INDEXES>
</TABLE>
<TABLE NAME="grade_import_newitem" COMMENT="temporary table for storing new grade_item names from grade import">
Expand Down
17 changes: 17 additions & 0 deletions lib/db/upgrade.php
Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion version.php
Expand Up @@ -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.

Expand Down

0 comments on commit be7a01b

Please sign in to comment.