Details
-
Type:
Bug
-
Status: Waiting for peer review
-
Priority:
Minor
-
Resolution: Unresolved
-
Affects Version/s: 3.9.2
-
Fix Version/s: None
-
Component/s: Assignment
-
Testing Instructions:
-
Affected Branches:MOODLE_39_STABLE
-
Pull from Repository:
-
Pull Master Branch:MDL-70049-master_count_submissions
Description
Tracker issue created from forum post: https://moodle.org/mod/forum/discuss.php?d=412662
During periods of high load when users are logging in, the function "count_submissions_need_grading" is causing the most load on our database server.
The function is called from mod_assign_core_calendar_provide_event_action but returning the count of submissions needing grading is returned even if the user does not have the capability of grading that item.
{{LINE 1549: mod_assign_core_calendar_provide_event_action: /mod/assign/lib.php}}
{{ if ($event->eventtype == ASSIGN_EVENT_TYPE_GRADINGDUE) {}}
{{ $name = get_string('grade');}}
{{ $url = new \moodle_url('/mod/assign/view.php', [}}
{{ 'id' => $cm->id,}}
{{ 'action' => 'grader'}}
{{ ]);}}
{{ $itemcount = $assign->count_submissions_need_grading();}}
{{ $actionable = $assign->can_grade($userid) && (time() >= $assign->get_instance()->allowsubmissionsfromdate);}}
{{ } else}}
The query used in $itemcount is expensive for MySQL to be run as it isn't using indexes in some parts, causes full table scans and also uses 2 temporary tables.
A better option would be checking if the user can grade the item or if it is actionable before counting submissions, and if not, assign "$itemcount = 0;" instead.