mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 04:30:15 +01:00
Merge branch 'MDL-66253' of https://github.com/NeillM/moodle
This commit is contained in:
commit
a756630e44
@ -278,7 +278,12 @@ class raw_event_retrieval_strategy implements raw_event_retrieval_strategy_inter
|
||||
|
||||
// Build the WHERE condition for the sub-query.
|
||||
if (!empty($subqueryconditions)) {
|
||||
$subquerywhere = 'WHERE ' . implode(" OR ", $subqueryconditions);
|
||||
$unionstartquery = "SELECT modulename, instance, eventtype, priority
|
||||
FROM {event} ev
|
||||
WHERE ";
|
||||
$subqueryunion = $unionstartquery . implode(" UNION $unionstartquery ", $subqueryconditions);
|
||||
} else {
|
||||
$subqueryunion = '{event}';
|
||||
}
|
||||
|
||||
// Merge subquery parameters to the parameters of the main query.
|
||||
@ -291,8 +296,7 @@ class raw_event_retrieval_strategy implements raw_event_retrieval_strategy_inter
|
||||
ev.instance,
|
||||
ev.eventtype,
|
||||
MIN(ev.priority) as priority
|
||||
FROM {event} ev
|
||||
$subquerywhere
|
||||
FROM ($subqueryunion) ev
|
||||
GROUP BY ev.modulename, ev.instance, ev.eventtype";
|
||||
|
||||
// Build the main query.
|
||||
|
@ -461,6 +461,8 @@
|
||||
<INDEX NAME="uuid" UNIQUE="false" FIELDS="uuid"/>
|
||||
<INDEX NAME="type-timesort" UNIQUE="false" FIELDS="type, timesort"/>
|
||||
<INDEX NAME="groupid-courseid-categoryid-visible-userid" UNIQUE="false" FIELDS="groupid, courseid, categoryid, visible, userid" COMMENT="used for calendar view"/>
|
||||
<INDEX NAME="eventtype" UNIQUE="false" FIELDS="eventtype"/>
|
||||
<INDEX NAME="modulename-instance" UNIQUE="false" FIELDS="modulename, instance"/>
|
||||
</INDEXES>
|
||||
</TABLE>
|
||||
<TABLE NAME="cache_filters" COMMENT="For keeping information about cached data">
|
||||
|
@ -2145,5 +2145,22 @@ function xmldb_main_upgrade($oldversion) {
|
||||
upgrade_main_savepoint(true, 2019122000.01);
|
||||
}
|
||||
|
||||
if ($oldversion < 2020010900.02) {
|
||||
$table = new xmldb_table('event');
|
||||
|
||||
// This index will improve the performance when the Events API retrieves category and group events.
|
||||
$index = new xmldb_index('eventtype', XMLDB_INDEX_NOTUNIQUE, ['eventtype']);
|
||||
if (!$dbman->index_exists($table, $index)) {
|
||||
$dbman->add_index($table, $index);
|
||||
}
|
||||
|
||||
// This index improves the performance of backups, deletion and visibilty changes on activities.
|
||||
$index = new xmldb_index('modulename-instance', XMLDB_INDEX_NOTUNIQUE, ['modulename', 'instance']);
|
||||
if (!$dbman->index_exists($table, $index)) {
|
||||
$dbman->add_index($table, $index);
|
||||
}
|
||||
|
||||
upgrade_main_savepoint(true, 2020010900.02);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user