diff --git a/db/install.xml b/db/install.xml
index 72eee3a35f..8cd3f61e13 100755
--- a/db/install.xml
+++ b/db/install.xml
@@ -85,6 +85,7 @@
+
diff --git a/db/upgrade.php b/db/upgrade.php
index 31f7ec55df..917fb3e770 100755
--- a/db/upgrade.php
+++ b/db/upgrade.php
@@ -731,6 +731,13 @@ function xmldb_attendance_upgrade($oldversion=0) {
upgrade_mod_savepoint(true, 2022083100, 'attendance');
}
if ($oldversion < 2022090900) {
+ $table = new xmldb_table('attendance_log');
+ $index = new xmldb_index('sessionid_studentid_statusid', XMLDB_KEY_UNIQUE, ['sessionid', 'studentid', 'statusid']);
+ // Conditionally launch add index sessionid_studentid_statusid.
+ if (!$dbman->index_exists($table, $index)) {
+ $dbman->add_index($table, $index);
+ }
+
if (!empty($CFG->dbfamily) && $CFG->dbfamily == 'postgres') {
$sql = 'DELETE FROM {attendance_log} a
WHERE a.id NOT IN (
@@ -814,5 +821,20 @@ function xmldb_attendance_upgrade($oldversion=0) {
upgrade_mod_savepoint(true, 2023020106, 'attendance');
}
+ if ($oldversion < 2023020109) {
+
+ // Add index on attendance_log for performance increase with update 2022090900.
+ $table = new xmldb_table('attendance_log');
+ $index = new xmldb_index('sessionid_studentid_statusid', XMLDB_KEY_UNIQUE, ['sessionid', 'studentid', 'statusid']);
+
+ // Conditionally launch add index sessionid_studentid_statusid.
+ if (!$dbman->index_exists($table, $index)) {
+ $dbman->add_index($table, $index);
+ }
+
+ // Attendance savepoint reached.
+ upgrade_mod_savepoint(true, 2023020109, 'attendance');
+ }
+
return true;
}
diff --git a/version.php b/version.php
index 11bb680b98..dc31ff3761 100755
--- a/version.php
+++ b/version.php
@@ -23,8 +23,8 @@
*/
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2023020108;
-$plugin->release = 2023020108;
+$plugin->version = 2023020109;
+$plugin->release = 2023020109;
$plugin->requires = 2022090200; // Requires 4.1.
$plugin->maturity = MATURITY_STABLE;
$plugin->cron = 0;