problem on the mdl_grade_grades_category moodle 2.8, high cpu use in my server of databases.

problem on the mdl_grade_grades_category moodle 2.8, high cpu use in my server of databases.

by Eduardo Miranda -
Number of replies: 3

hi everyone,

I want to comment a problem that appeared to me in the new Moodle 2.8 version, whenever teachers enter to the report "grade history",  my database's server CPU goes to 100% usage, the query that is running is:


MySQL mdl_grade_grades_history select

SELECT ggh.id, ggh.timemodified, ggh.itemid, ggh.userid, ggh.finalgrade, ggh.usermodified, ggh.source, ggh.overridden, ggh.locked, ggh.excluded, ggh.feedback, ggh.feedbackformat, gi.itemtype, gi.itemmodule, gi.iteminstance, gi.itemnumber, u.idnumber, u.email, u.firstnamephonetic,u.lastnamephonetic,u.middlename,u.alternatename,u.firstname,u.lastname, ug.firstnamephonetic AS graderfirstnamephonetic,ug.lastnamephonetic AS graderlastnamephonetic,ug.middlename...More...
SELECT ggh.id, ggh.timemodified, ggh.itemid, ggh.userid, ggh.finalgrade, ggh.usermodified, ggh.source, ggh.overridden, ggh.locked, ggh.excluded, ggh.feedback, ggh.feedbackformat, gi.itemtype, gi.itemmodule, gi.iteminstance, gi.itemnumber, u.idnumber, u.email, u.firstnamephonetic,u.lastnamephonetic,u.middlename,u.alternatename,u.firstname,u.lastname, ug.firstnamephonetic AS graderfirstnamephonetic,ug.lastnamephonetic AS graderlastnamephonetic,ug.middlename AS gradermiddlename,ug.alternatename AS graderalternatename,ug.firstname AS graderfirstname,ug.lastname AS graderlastname, (SELECT MAX(finalgrade) FROM mdl_grade_grades_history h WHERE h.itemid = ggh.itemid AND h.userid = ggh.userid AND h.timemodified < ggh.timemodified AND NOT EXISTS ( SELECT ? FROM mdl_grade_grades_history h? WHERE h?.itemid = ggh.itemid AND h?.userid = ggh.userid AND h?.timemodified < ggh.timemodified AND h.timemodified < h?.timemodified)) AS prevgrade, CASE WHEN gi.itemname IS NULL THEN gi.itemtype ELSE gi.itemname END AS itemname FROM mdl_grade_grades_history ggh LEFT JOIN mdl_grade_items gi ON gi.id = ggh.itemid JOIN mdl_user u ON u.id = ggh.userid LEFT JOIN mdl_user ug ON ug.id = ggh.usermodified WHERE gi.courseid = ? ORDER BY timemodified DESC, id DESC LIMIT ?, ?
Average of ratings: Useful (1)
In reply to Eduardo Miranda

Re: problem on the mdl_grade_grades_category moodle 2.8, high cpu use in my server of databases.

by George Mihailov -

We experienced same problem and it was solved by adding in index


create index mdl_gradgradhist_finalgra_ix on mdl_grade_grades_history (itemid,userid,timemodified) using hash;
Average of ratings: Useful (2)
In reply to George Mihailov

Re: problem on the mdl_grade_grades_category moodle 2.8, high cpu use in my server of databases.

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Did anybody bother to raise a tracker report for this? smile