MDL-31617 add course sortorder index to improve perf

This commit is contained in:
Petr Skoda 2012-05-05 10:55:57 +02:00
parent e16e2300c5
commit c119a2eeb5
3 changed files with 20 additions and 4 deletions

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<XMLDB PATH="lib/db" VERSION="20120504" COMMENT="XMLDB file for core Moodle tables"
<XMLDB PATH="lib/db" VERSION="20120505" COMMENT="XMLDB file for core Moodle tables"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../lib/xmldb/xmldb.xsd"
>
@ -109,7 +109,8 @@
<INDEXES>
<INDEX NAME="category" UNIQUE="false" FIELDS="category" NEXT="idnumber"/>
<INDEX NAME="idnumber" UNIQUE="false" FIELDS="idnumber" PREVIOUS="category" NEXT="shortname"/>
<INDEX NAME="shortname" UNIQUE="false" FIELDS="shortname" PREVIOUS="idnumber"/>
<INDEX NAME="shortname" UNIQUE="false" FIELDS="shortname" PREVIOUS="idnumber" NEXT="sortorder"/>
<INDEX NAME="sortorder" UNIQUE="false" FIELDS="sortorder" PREVIOUS="shortname"/>
</INDEXES>
</TABLE>
<TABLE NAME="course_categories" COMMENT="Course categories" PREVIOUS="course" NEXT="course_completion_aggr_methd">
@ -2819,4 +2820,4 @@
</KEYS>
</TABLE>
</TABLES>
</XMLDB>
</XMLDB>

View File

@ -478,5 +478,20 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2012050300.05);
}
if ($oldversion < 2012050400.01) {
// Define index sortorder (not unique) to be added to course
$table = new xmldb_table('course');
$index = new xmldb_index('sortorder', XMLDB_INDEX_NOTUNIQUE, array('sortorder'));
// Conditionally launch add index sortorder
if (!$dbman->index_exists($table, $index)) {
$dbman->add_index($table, $index);
}
// Main savepoint reached
upgrade_main_savepoint(true, 2012050400.01);
}
return true;
}

View File

@ -30,7 +30,7 @@
defined('MOODLE_INTERNAL') || die();
$version = 2012050400.00; // YYYYMMDD = weekly release date of this DEV branch
$version = 2012050400.01; // YYYYMMDD = weekly release date of this DEV branch
// RR = release increments - 00 in DEV branches
// .XX = incremental changes