Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#140] Add index for dialogueid for performance improvement #141

Merged
merged 2 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 < 2024120900) {
// 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, 2024120900, '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 = 2024120900;
$plugin->release = 2024100901;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we please bump the release version at the same time?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @danmarsden

I've bumped the release version as well

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