Skip to content

Commit

Permalink
MDL-52334 enrol_database: Add missing filter to user_enrolment lookup
Browse files Browse the repository at this point in the history
Without the user filter, the left join to the user enrolment table
results in a much larger set of data being returned than before
MDL-28420. Which makes login time for users in many busy courses much
worse than before (3x worse on average, observed upto 40x).
  • Loading branch information
aolley committed Dec 8, 2015
1 parent ea5c18d commit 6c9b668
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions enrol/database/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,9 @@ public function sync_user_enrolments($user) {
FROM {enrol} e
JOIN {course} c ON c.id = e.courseid
JOIN {role_assignments} ra ON ra.itemid = e.id
LEFT JOIN {user_enrolments} ue ON ue.enrolid = e.id
LEFT JOIN {user_enrolments} ue ON ue.enrolid = e.id AND ue.userid = ra.userid
WHERE ra.userid = :userid AND e.enrol = 'database'";
$rs = $DB->get_recordset_sql($sql, array('userid'=>$user->id));
$rs = $DB->get_recordset_sql($sql, array('userid' => $user->id));
foreach ($rs as $instance) {
if (!$instance->cvisible and $ignorehidden) {
continue;
Expand Down

0 comments on commit 6c9b668

Please sign in to comment.