Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

MDL-31495 Performance improvement in question engine upgrade SQL

  • Loading branch information...
commit 2af7d0d8d01bc9c4aace3e9e44ffcd04e860c598 1 parent 722b55d
Michael Aherne authored February 08, 2012

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

  1. 20  question/engine/upgrade/upgradelib.php
20  question/engine/upgrade/upgradelib.php
@@ -155,19 +155,19 @@ public function update_all_attempts_at_quiz($quiz) {
155 155
 
156 156
         $quizattemptsrs = $DB->get_recordset_select('quiz_attempts', $where, $params, 'uniqueid');
157 157
         $questionsessionsrs = $DB->get_recordset_sql("
158  
-                SELECT *
159  
-                FROM {question_sessions}
160  
-                WHERE attemptid IN (
161  
-                    SELECT uniqueid FROM {quiz_attempts} WHERE $where)
162  
-                ORDER BY attemptid, questionid
  158
+                SELECT s.*
  159
+                  FROM {question_sessions} s
  160
+                  JOIN {quiz_attempts} a ON (attemptid = uniqueid)
  161
+                 WHERE $where
  162
+              ORDER BY attemptid, questionid
163 163
         ", $params);
164 164
 
165 165
         $questionsstatesrs = $DB->get_recordset_sql("
166  
-                SELECT *
167  
-                FROM {question_states}
168  
-                WHERE attempt IN (
169  
-                    SELECT uniqueid FROM {quiz_attempts} WHERE $where)
170  
-                ORDER BY attempt, question, seq_number, id
  166
+                SELECT s.*
  167
+                  FROM {question_states} s
  168
+                  JOIN {quiz_attempts} ON (s.attempt = uniqueid)
  169
+                 WHERE $where
  170
+              ORDER BY s.attempt, question, seq_number, s.id
171 171
         ", $params);
172 172
 
173 173
         $datatodo = $quizattemptsrs && $questionsessionsrs && $questionsstatesrs;

0 notes on commit 2af7d0d

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