Issue Details (XML | Word | Printable)

Key: MDL-12829
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Blocker Blocker
Assignee: Nicolas Connault
Reporter: Nicolas Connault
Votes: 0
Watchers: 0
Operations

Add/Edit UI Mockup to this issue
If you were logged in you would be able to see more operations.
Moodle

1.8 -> 1.9 upgrade freezes during quiz upgrade

Created: 04/Jan/08 03:24 PM   Updated: Yesterday 01:47 PM
Return to search
Component/s: Quiz
Affects Version/s: 1.9
Fix Version/s: 1.9

Database: MySQL
Participants: Andrew Davis, Martin Dougiamas, Nicolas Connault and Tim Hunt
Security Level: None
QA Assignee: Andrew Davis
Resolved date: 09/Jan/08
Affected Branches: MOODLE_19_STABLE
Fixed Branches: MOODLE_19_STABLE


 Description  « Hide
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!

 All   Comments   Change History   Version Control      Sort Order: Ascending order - Click to sort in descending order
Nicolas Connault added a comment - 04/Jan/08 03:25 PM
SQL fix applied and tested with the same test data. Upgrade completes without problems.

Tim Hunt added a comment - 08/Jan/08 10:04 PM
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.


Martin Dougiamas added a comment - 08/Jan/08 10:13 PM
Nicolas can you sort this out today? (good catch Tim)

Nicolas Connault added a comment - 09/Jan/08 12:26 AM
Sorry about that. My CVS client was buggy (updated now...)

Andrew Davis added a comment - 24/Nov/09 01:47 PM
Better query is in 1.9 and 2. Upgrade occurs without a problem. Closing.