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

perf(db): add index to improve query times #197

Merged
merged 2 commits into from
Oct 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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 .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ jobs:
uses: catalyst/catalyst-moodle-workflows/.github/workflows/ci.yml@main
with:
disable_behat: true
disable_phpdoc: true
7 changes: 5 additions & 2 deletions db/install.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<XMLDB PATH="admin/tool/trigger/db" VERSION="20210224" COMMENT="XMLDB file for Moodle admin/tool/trigger"
<XMLDB PATH="admin/tool/trigger/db" VERSION="20221018" COMMENT="XMLDB file for Moodle admin/tool/trigger"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../lib/xmldb/xmldb.xsd"
>
Expand Down Expand Up @@ -161,6 +161,9 @@
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
<KEY NAME="eventid" TYPE="foreign" FIELDS="eventid" REFTABLE="tool_trigger_events" REFFIELDS="id" COMMENT="Relates to the event id in the events table."/>
</KEYS>
<INDEXES>
<INDEX NAME="workflowid-number" UNIQUE="false" FIELDS="workflowid, number"/>
</INDEXES>
</TABLE>
<TABLE NAME="tool_trigger_run_hist" COMMENT="Table to store run history">
<FIELDS>
Expand Down Expand Up @@ -192,4 +195,4 @@
</INDEXES>
</TABLE>
</TABLES>
</XMLDB>
</XMLDB>
15 changes: 15 additions & 0 deletions db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -350,5 +350,20 @@ function xmldb_tool_trigger_upgrade($oldversion) {
upgrade_plugin_savepoint(true, 2021030404, 'tool', 'trigger');
}

if ($oldversion < 2021030408) {

// Define index workflowid-number (not unique) to be added to tool_trigger_workflow_hist.
$table = new xmldb_table('tool_trigger_workflow_hist');
$index = new xmldb_index('workflowid-number', XMLDB_INDEX_NOTUNIQUE, ['workflowid', 'number']);

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

// Trigger savepoint reached.
upgrade_plugin_savepoint(true, 2021030408, 'tool', 'trigger');
}

return true;
}
4 changes: 2 additions & 2 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
defined('MOODLE_INTERNAL') || die();

$plugin->component = 'tool_trigger';
$plugin->release = 2021030407;
$plugin->version = 2021030407;
$plugin->release = 2021030408;
$plugin->version = 2021030408;
$plugin->requires = 2016052300;
$plugin->supported = [35, 310];
$plugin->maturity = MATURITY_STABLE;
Expand Down