-
Bug
-
Resolution: Fixed
-
Critical
-
2.4.6, 2.5.2
-
MOODLE_24_STABLE, MOODLE_25_STABLE
-
MOODLE_24_STABLE, MOODLE_25_STABLE
-
MDL-42065_master -
We are noticing significant slowness on a site that has a large number of total grade items (in some cases > 1,000 grade items in multiple courses). Both queries could be optimized to include the grade_category or grade_item courseid (both indexed).
Query 1
SELECT gi.id |
FROM mdl_grade_items gi |
WHERE (gi.gradetype = '1' OR gi.gradetype = '2') |
AND gi.outcomeid IS NULL |
AND gi.categoryid IN ( |
SELECT gc.id |
FROM mdl_grade_categories gc |
WHERE gc.path LIKE '%/9820/%' |
)
|
Query 2
SELECT gi.id |
FROM mdl_grade_items gi |
WHERE (gi.gradetype = ? OR gi.gradetype = ?) |
AND gi.categoryid = ? |
AND gi.outcomeid IS NULL |
|
UNION
|
|
SELECT gi.id FROM mdl_grade_items gi, mdl_grade_categories gc |
WHERE (gi.itemtype = ? OR gi.itemtype = ?) |
AND gi.iteminstance=gc.id |
AND gc.parent = ? |
AND (gi.gradetype = ? OR gi.gradetype = ?) |
AND gi.outcomeid IS NULL |