MDL-57980 grade_items: add mdl_grade_items index

New index created on itemtype, itemmodule, iteminstance and courseid
This commit is contained in:
Alex Rowe 2021-09-24 15:25:09 +10:00
parent 1a9bee69e6
commit 5ea613c99b
3 changed files with 18 additions and 2 deletions

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<XMLDB PATH="lib/db" VERSION="20210728" COMMENT="XMLDB file for core Moodle tables"
<XMLDB PATH="lib/db" VERSION="20211005" COMMENT="XMLDB file for core Moodle tables"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../lib/xmldb/xmldb.xsd"
>
@ -1917,6 +1917,7 @@
<INDEX NAME="itemtype-needsupdate" UNIQUE="false" FIELDS="itemtype, needsupdate" COMMENT="used in grading cron"/>
<INDEX NAME="gradetype" UNIQUE="false" FIELDS="gradetype" COMMENT="index for gradetype"/>
<INDEX NAME="idnumber-courseid" UNIQUE="false" FIELDS="idnumber, courseid" COMMENT="non unique index (although programatically we are guarantying some sort of uniqueness both under this table and the course_modules one). TODO: We need a central store of module idnumbers in the future."/>
<INDEX NAME="itemtype-mod-inst-course" UNIQUE="false" FIELDS="itemtype, itemmodule, iteminstance, courseid" COMMENT="used in grading and course views"/>
</INDEXES>
</TABLE>
<TABLE NAME="grade_grades" COMMENT="grade_grades This table keeps individual grades for each user and each item, exactly as imported or submitted by modules. The rawgrademax/min and rawscaleid are stored here to record the values at the time the grade was stored, because teachers might change this for an activity! All the results are normalised/resampled for the final grade value.">

View File

@ -2862,5 +2862,20 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2021092400.03);
}
if ($oldversion < 2021100500.00) {
// Define index itemtype-mod-inst-course (not unique) to be added to grade_items.
$table = new xmldb_table('grade_items');
$index = new xmldb_index('itemtype-mod-inst-course', XMLDB_INDEX_NOTUNIQUE,
['itemtype', 'itemmodule', 'iteminstance', 'courseid']);
// Conditionally launch add index itemtype-mod-inst-course.
if (!$dbman->index_exists($table, $index)) {
$dbman->add_index($table, $index);
}
// Main savepoint reached.
upgrade_main_savepoint(true, 2021100500.00);
}
return true;
}

View File

@ -29,7 +29,7 @@
defined('MOODLE_INTERNAL') || die();
$version = 2021100300.00; // YYYYMMDD = weekly release date of this DEV branch.
$version = 2021100500.00; // YYYYMMDD = weekly release date of this DEV branch.
// RR = release increments - 00 in DEV branches.
// .XX = incremental changes.
$release = '4.0dev (Build: 20211003)'; // Human-friendly version name