mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 21:49:15 +01:00
MDL-77965 calendar: Improve performance of data extract
The UNION caused the query to be run in a way that is very inefficient on MySQL, separating the queries causes each of them to run in a much more efficient form. Any duplicated will be filtered out on the PHP side instead of in the database. On large Moodle sites this is preferable as the extract is likely to be performed on a server dedicated to running the Moodle cron and so there will be less of effect on resources that are used to serve end users.
This commit is contained in:
parent
081bfd0a9d
commit
18a964324b
@ -118,9 +118,9 @@ class provider implements
|
||||
(e.courseid = ctx.instanceid AND e.eventtype = 'course' AND ctx.contextlevel = :coursecontext) OR
|
||||
(e.courseid = ctx.instanceid AND e.eventtype = 'group' AND ctx.contextlevel = :groupcontext) OR
|
||||
(e.userid = ctx.instanceid AND e.eventtype = 'user' AND ctx.contextlevel = :usercontext)
|
||||
WHERE e.userid = :cuserid
|
||||
UNION
|
||||
SELECT ctx.id
|
||||
WHERE e.userid = :cuserid";
|
||||
$contextlist->add_from_sql($sql, $params);
|
||||
$sql = "SELECT ctx.id
|
||||
FROM {context} ctx
|
||||
JOIN {course_modules} cm ON cm.id = ctx.instanceid AND ctx.contextlevel = :modulecontext
|
||||
JOIN {modules} m ON m.id = cm.module
|
||||
|
Loading…
x
Reference in New Issue
Block a user