-
Bug
-
Resolution: Fixed
-
Critical
-
2.3.1
-
None
-
MOODLE_23_STABLE
-
MOODLE_23_STABLE
-
Removing grade override on an assignment (2.3) grade creates a row in mdl_grade_grades for all users in mdl_user table for that grade item. This is causing performance problems on sites with a large number of users. For sites with a large number of users this will cause the script to run out of memory and never completely finish.
To reproduce:
1. Run this query to see how many mdl_grade_grades the guest user has:
SELECT COUNT FROM mdl_grade_grades WHERE userid = 1 LIMIT 1;
2. Create a course.
3. Add an assignment (2.3 not older 2.2)
4. Add 1 user as a student to course, but not guest user.
5. Turn on editing in gradebook and type a grade in the assignment and update.
6. Edit the grade and uncheck the "Overridden" check box and save changes. For sites with a large number of users this will cause the script to run out of memory.
7. Run this query to see how many mdl_grade_grades the guest user has:
SELECT COUNT FROM mdl_grade_grades WHERE userid = 1 LIMIT 1;
You will see that count has increased.
Running
SELECT userid, COUNT FROM mdl_grade_grades WHERE itemid IN (SELECT itemid FROM mdl_grade_grades WHERE userid = 1) GROUP BY userid ORDER BY userid LIMIT 30;
will help convince you that it is creating rows for all users for that itemid.