MDL-86601 core_task: Add index for large adhoc task queues

This commit is contained in:
Benjamin Walker
2026-01-30 22:52:19 +10:00
parent 59fd844136
commit 4a2cf5131b
2 changed files with 16 additions and 1 deletions
+2 -1
View File
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<XMLDB PATH="lib/db" VERSION="20251205" COMMENT="XMLDB file for core Moodle tables"
<XMLDB PATH="lib/db" VERSION="20251208" COMMENT="XMLDB file for core Moodle tables"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../lib/xmldb/xmldb.xsd"
>
@@ -3523,6 +3523,7 @@
<INDEXES>
<INDEX NAME="nextruntime_idx" UNIQUE="false" FIELDS="nextruntime"/>
<INDEX NAME="timestarted_idx" UNIQUE="false" FIELDS="timestarted"/>
<INDEX NAME="nextruntime_classname" UNIQUE="false" FIELDS="nextruntime, classname"/>
</INDEXES>
</TABLE>
<TABLE NAME="task_log" COMMENT="The log table for all tasks">
+14
View File
@@ -1952,5 +1952,19 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2025041404.06);
}
if ($oldversion < 2025041404.08) {
// Define index nextruntime_classname (not unique) to be added to task_adhoc.
$table = new xmldb_table('task_adhoc');
$index = new xmldb_index('nextruntime_classname', XMLDB_INDEX_NOTUNIQUE, ['nextruntime', 'classname']);
// Conditionally launch add index nextruntime_classname.
if (!$dbman->index_exists($table, $index)) {
$dbman->add_index($table, $index);
}
// Main savepoint reached.
upgrade_main_savepoint(true, 2025041404.08);
}
return true;
}