Skip to content

Commit

Permalink
MDL-31495 Performance improvement in question engine upgrade SQL
Browse files Browse the repository at this point in the history
  • Loading branch information
micaherne authored and Aparup Banerjee committed Feb 15, 2012
1 parent 042e24f commit e0325d3
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions question/engine/upgrade/upgradelib.php
Expand Up @@ -154,19 +154,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;
Expand Down

0 comments on commit e0325d3

Please sign in to comment.