MDL-45642 questions: add required index to question_attempts.

It is important to be able to tell which behaviours are in use, and
without this index, it requires a complete scan of this table, which can
be very big, to verify that a behaviour is unused.
This commit is contained in:
Tim Hunt
2014-08-12 11:37:50 +01:00
committed by Dan Poltawski
parent 82b7d129d7
commit b483b31dab
3 changed files with 17 additions and 1 deletions
+1
View File
@@ -1405,6 +1405,7 @@
</KEYS>
<INDEXES>
<INDEX NAME="questionusageid-slot" UNIQUE="true" FIELDS="questionusageid, slot"/>
<INDEX NAME="behaviour" UNIQUE="false" FIELDS="behaviour" COMMENT="Required because we need to be able to determine efficiently which behaviours are in use."/>
</INDEXES>
</TABLE>
<TABLE NAME="question_attempt_steps" COMMENT="Stores one step in in a question attempt. As well as the data here, the step will have some data in the question_attempt_step_data table.">
+15
View File
@@ -3003,5 +3003,20 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2013111804.03);
}
if ($oldversion < 2013111804.06) {
// Define index behaviour (not unique) to be added to question_attempts.
$table = new xmldb_table('question_attempts');
$index = new xmldb_index('behaviour', XMLDB_INDEX_NOTUNIQUE, array('behaviour'));
// Conditionally launch add index behaviour.
if (!$dbman->index_exists($table, $index)) {
$dbman->add_index($table, $index);
}
// Main savepoint reached.
upgrade_main_savepoint(true, 2013111804.06);
}
return true;
}
+1 -1
View File
@@ -29,7 +29,7 @@
defined('MOODLE_INTERNAL') || die();
$version = 2013111804.05; // 20131118 = branching date YYYYMMDD - do not modify!
$version = 2013111804.06; // 20131118 = branching date YYYYMMDD - do not modify!
// RR = release increments - 00 in DEV branches.
// .XX = incremental changes.