Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

MDL-34156 Remove subselect from slow query

  • Loading branch information...
commit c82d7fc832d9ef4b0f2a6b1bba77049414b9c358 1 parent 1f34fa7
Michael Aherne micaherne authored danpoltawski committed

Showing 1 changed file with 3 additions and 4 deletions. Show diff stats Hide diff stats

  1. +3 4 enrol/meta/locallib.php
7 enrol/meta/locallib.php
@@ -477,11 +477,10 @@ function enrol_meta_sync($courseid = NULL, $verbose = false) {
477 477 $sql = "SELECT ue.*
478 478 FROM {user_enrolments} ue
479 479 JOIN {enrol} e ON (e.id = ue.enrolid AND e.enrol = 'meta' $onecourse)
480   - LEFT JOIN (SELECT xpue.userid, xpe.courseid
481   - FROM {user_enrolments} xpue
  480 + LEFT JOIN ({user_enrolments} xpue
482 481 JOIN {enrol} xpe ON (xpe.id = xpue.enrolid AND xpe.enrol <> 'meta' AND xpe.enrol $enabled)
483   - ) pue ON (pue.courseid = e.customint1 AND pue.userid = ue.userid)
484   - WHERE pue.userid IS NULL";
  482 + ) ON (xpe.courseid = e.customint1 AND xpue.userid = ue.userid)
  483 + WHERE xpue.userid IS NULL";
485 484 $rs = $DB->get_recordset_sql($sql, $params);
486 485 foreach($rs as $ue) {
487 486 if (!isset($instances[$ue->enrolid])) {

0 comments on commit c82d7fc

Please sign in to comment.
Something went wrong with that request. Please try again.