From 4a2cf5131bb5d073fa78b6ad262966ec9ebfd353 Mon Sep 17 00:00:00 2001 From: Benjamin Walker Date: Wed, 17 Sep 2025 09:40:17 +1000 Subject: [PATCH] MDL-86601 core_task: Add index for large adhoc task queues --- lib/db/install.xml | 3 ++- lib/db/upgrade.php | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/db/install.xml b/lib/db/install.xml index b3fea5c3a98..cc89357d8d1 100644 --- a/lib/db/install.xml +++ b/lib/db/install.xml @@ -1,5 +1,5 @@ - @@ -3523,6 +3523,7 @@ + diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index d36a746273b..522c4600608 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -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; }