Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-31495 Performance improvement in question engine upgrade SQL

  • Loading branch information...
commit 2af7d0d8d01bc9c4aace3e9e44ffcd04e860c598 1 parent 722b55d
Michael Aherne micaherne authored
Showing with 10 additions and 10 deletions.
  1. +10 −10 question/engine/upgrade/upgradelib.php
20 question/engine/upgrade/upgradelib.php
View
@@ -155,19 +155,19 @@ public function update_all_attempts_at_quiz($quiz) {
$quizattemptsrs = $DB->get_recordset_select('quiz_attempts', $where, $params, 'uniqueid');
$questionsessionsrs = $DB->get_recordset_sql("
- SELECT *
- FROM {question_sessions}
- WHERE attemptid IN (
- SELECT uniqueid FROM {quiz_attempts} WHERE $where)
- ORDER BY attemptid, questionid
+ SELECT s.*
+ FROM {question_sessions} s
+ JOIN {quiz_attempts} a ON (attemptid = uniqueid)
+ WHERE $where
+ ORDER BY attemptid, questionid
", $params);
$questionsstatesrs = $DB->get_recordset_sql("
- SELECT *
- FROM {question_states}
- WHERE attempt IN (
- SELECT uniqueid FROM {quiz_attempts} WHERE $where)
- ORDER BY attempt, question, seq_number, id
+ SELECT s.*
+ FROM {question_states} s
+ JOIN {quiz_attempts} ON (s.attempt = uniqueid)
+ WHERE $where
+ ORDER BY s.attempt, question, seq_number, s.id
", $params);
$datatodo = $quizattemptsrs && $questionsessionsrs && $questionsstatesrs;
Please sign in to comment.
Something went wrong with that request. Please try again.