Permalink
Browse files

MDL-34156 Remove subselect from slow query

  • Loading branch information...
1 parent 1f34fa7 commit c82d7fc832d9ef4b0f2a6b1bba77049414b9c358 @micaherne micaherne committed with danpoltawski Jul 3, 2012
Showing with 3 additions and 4 deletions.
  1. +3 −4 enrol/meta/locallib.php
View
7 enrol/meta/locallib.php
@@ -477,11 +477,10 @@ function enrol_meta_sync($courseid = NULL, $verbose = false) {
$sql = "SELECT ue.*
FROM {user_enrolments} ue
JOIN {enrol} e ON (e.id = ue.enrolid AND e.enrol = 'meta' $onecourse)
- LEFT JOIN (SELECT xpue.userid, xpe.courseid
- FROM {user_enrolments} xpue
+ LEFT JOIN ({user_enrolments} xpue
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)
- WHERE pue.userid IS NULL";
+ ) ON (xpe.courseid = e.customint1 AND xpue.userid = ue.userid)
+ WHERE xpue.userid IS NULL";
$rs = $DB->get_recordset_sql($sql, $params);
foreach($rs as $ue) {
if (!isset($instances[$ue->enrolid])) {

0 comments on commit c82d7fc

Please sign in to comment.