Moodle

1.8 -> 1.9 upgrade freezes during quiz upgrade

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Blocker Blocker
  • Resolution: Fixed
  • Affects Version/s: 1.9
  • Fix Version/s: 1.9
  • Component/s: Quiz
  • Labels:
    None
  • Database:
    MySQL
  • Affected Branches:
    MOODLE_19_STABLE
  • Fixed Branches:
    MOODLE_19_STABLE

Description

A badly designed query slows the upgrade down to a crawl on a live site using quizzes:

SELECT u.id, u.id AS userid, g.grade AS rawgrade, g.timemodified AS dategraded, a.timefinish AS datesubmitted
FROM user u, quiz_grades g, quiz_attempts a
WHERE u.id = g.userid AND g.quiz = 8
AND a.timefinish = (SELECT MAX(aa.timefinish) FROM quiz_attempts aa WHERE aa.quiz = 8 AND aa.userid = u.id AND aa.preview = 0) ;

The correct way to get the desired results is:

SELECT u.id, u.id AS userid, g.grade AS rawgrade, g.timemodified AS dategraded, MAX(a.timefinish) AS datesubmitted
FROM user u, quiz_grades g, quiz_attempts a
WHERE u.id = g.userid AND g.quiz = 8 AND u.id = a.userid AND a.quiz = 8
GROUP BY u.id, g.grade, g.timemodified;

Which executes super-fast. Thanks Eloy for your analysis!

Activity

Hide
Nicolas Connault added a comment -

SQL fix applied and tested with the same test data. Upgrade completes without problems.

Show
Nicolas Connault added a comment - SQL fix applied and tested with the same test data. Upgrade completes without problems.
Hide
Tim Hunt added a comment -

Nicholas, looks like you Committed twice to head, and not at all to the branch.

http://cvs.moodle.org/moodle/mod/quiz/lib.php

Look where the MOODLE_19_MERGED tag is.

Show
Tim Hunt added a comment - Nicholas, looks like you Committed twice to head, and not at all to the branch. http://cvs.moodle.org/moodle/mod/quiz/lib.php Look where the MOODLE_19_MERGED tag is.
Hide
Martin Dougiamas added a comment -

Nicolas can you sort this out today? (good catch Tim)

Show
Martin Dougiamas added a comment - Nicolas can you sort this out today? (good catch Tim)
Hide
Nicolas Connault added a comment -

Sorry about that. My CVS client was buggy (updated now...)

Show
Nicolas Connault added a comment - Sorry about that. My CVS client was buggy (updated now...)
Hide
Andrew Davis added a comment -

Better query is in 1.9 and 2. Upgrade occurs without a problem. Closing.

Show
Andrew Davis added a comment - Better query is in 1.9 and 2. Upgrade occurs without a problem. Closing.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: