Skip to content

Commit

Permalink
MDL-69190 grade: fix slow query.
Browse files Browse the repository at this point in the history
  • Loading branch information
danmarsden authored and andrewnicols committed Sep 2, 2020
1 parent d179137 commit 58bf730
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions grade/report/grader/lib.php
Expand Up @@ -1531,9 +1531,7 @@ public function get_right_avg_row($rows=array(), $grouponly=false) {
// This query returns a count of ungraded grades (NULL finalgrade OR no matching record in grade_grades table)
$sql = "SELECT gi.id, COUNT(DISTINCT u.id) AS count
FROM {grade_items} gi
CROSS JOIN {user} u
JOIN ($enrolledsql) je
ON je.id = u.id
CROSS JOIN ($enrolledsql) u
JOIN {role_assignments} ra
ON ra.userid = u.id
LEFT OUTER JOIN {grade_grades} g
Expand All @@ -1542,7 +1540,6 @@ public function get_right_avg_row($rows=array(), $grouponly=false) {
WHERE gi.courseid = :courseid
AND ra.roleid $gradebookrolessql
AND ra.contextid $relatedctxsql
AND u.deleted = 0
AND g.id IS NULL
$groupwheresql
GROUP BY gi.id";
Expand Down

0 comments on commit 58bf730

Please sign in to comment.