Skip to content

Commit

Permalink
MDL-34156 Remove subselect from slow query
Browse files Browse the repository at this point in the history
  • Loading branch information
micaherne authored and danpoltawski committed Jul 10, 2012
1 parent 1f34fa7 commit c82d7fc
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions enrol/meta/locallib.php
Expand Up @@ -477,11 +477,10 @@ function enrol_meta_sync($courseid = NULL, $verbose = false) {
$sql = "SELECT ue.* $sql = "SELECT ue.*
FROM {user_enrolments} ue FROM {user_enrolments} ue
JOIN {enrol} e ON (e.id = ue.enrolid AND e.enrol = 'meta' $onecourse) JOIN {enrol} e ON (e.id = ue.enrolid AND e.enrol = 'meta' $onecourse)
LEFT JOIN (SELECT xpue.userid, xpe.courseid LEFT JOIN ({user_enrolments} xpue
FROM {user_enrolments} xpue
JOIN {enrol} xpe ON (xpe.id = xpue.enrolid AND xpe.enrol <> 'meta' AND xpe.enrol $enabled) JOIN {enrol} xpe ON (xpe.id = xpue.enrolid AND xpe.enrol <> 'meta' AND xpe.enrol $enabled)
) pue ON (pue.courseid = e.customint1 AND pue.userid = ue.userid) ) ON (xpe.courseid = e.customint1 AND xpue.userid = ue.userid)
WHERE pue.userid IS NULL"; WHERE xpue.userid IS NULL";
$rs = $DB->get_recordset_sql($sql, $params); $rs = $DB->get_recordset_sql($sql, $params);
foreach($rs as $ue) { foreach($rs as $ue) {
if (!isset($instances[$ue->enrolid])) { if (!isset($instances[$ue->enrolid])) {
Expand Down

0 comments on commit c82d7fc

Please sign in to comment.