Skip to content

Commit

Permalink
[#140] Add index for dialogueid for performance improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
jwalits committed Dec 9, 2024
1 parent ee40096 commit e88e0d5
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions db/install.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
<INDEXES>
<INDEX NAME="authorid" UNIQUE="false" FIELDS="authorid"/>
<INDEX NAME="conversationid" UNIQUE="false" FIELDS="conversationid"/>
<INDEX NAME="dialogueid" UNIQUE="false" FIELDS="dialogueid"/>
</INDEXES>
</TABLE>
<TABLE NAME="dialogue_flags" COMMENT="Flags set against a dialogue, conversation or message e.g read">
Expand Down
18 changes: 18 additions & 0 deletions db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,23 @@
* @return bool
*/
function xmldb_dialogue_upgrade($oldversion) {
global $DB;

$dbman = $DB->get_manager();

if ($oldversion < 2024120400) {
// Define index dialogueid (not unique) to be added to dialogue_messages.
$table = new xmldb_table('dialogue_messages');
$index = new xmldb_index('dialogueid', XMLDB_INDEX_NOTUNIQUE, ['dialogueid']);

// Conditionally launch add index userid.
if (!$dbman->index_exists($table, $index)) {
$dbman->add_index($table, $index);
}

// savepoint reached.
upgrade_mod_savepoint(true, 2024120400, 'dialogue');
}

return true;
}
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/
defined('MOODLE_INTERNAL') || die();

$plugin->version = 2024100901;
$plugin->version = 2024120400;
$plugin->release = 2024100901;
$plugin->requires = 2022112805; // Requires 4.1 or higher.
$plugin->component = 'mod_dialogue'; // Full name of the plugin (used for diagnostics).
Expand Down

0 comments on commit e88e0d5

Please sign in to comment.