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:
@@ -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.">
|
||||
|
||||
@@ -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
@@ -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.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user