-
Bug
-
Resolution: Unresolved
-
Major
-
None
-
3.11.12, 4.0.6, 4.1.1
After upgrading a Moodle site >= 3.11.2 an adhoc task is created for the assignfeedback_editpdf plugin to bump stale submissions in the files table to ensure documents are converted. Several joins in the query used to gather these submissions are joined off index resulting in full table scans and joins resulting in huge search sets.
For one of our customers we can see the explain plan evaluating several million rows at each stage of the query:
+------+-------------+-------+--------+------------------------------------------------------------------------------------------------------------+----------------------------+---------+-----------------------------------------------------+----------+------------------------------------+
|
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
|
+------+-------------+-------+--------+------------------------------------------------------------------------------------------------------------+----------------------------+---------+-----------------------------------------------------+----------+------------------------------------+
|
| 1 | SIMPLE | f1 | ALL | NULL | NULL | NULL | NULL | 20923425 | Using where | |
| 1 | SIMPLE | asu | eq_ref | PRIMARY,mdl_assisubm_assusegroatt_uix,mdl_assisubm_use_ix,mdl_assisubm_ass_ix,mdl_assisubm_assusegrolat_ix | PRIMARY | 8 | moodle_customer.f1.itemid | 1 | | |
| 1 | SIMPLE | asg | ref | PRIMARY,mdl_assigrad_assuseatt_uix,mdl_assigrad_use_ix,mdl_assigrad_ass_ix | mdl_assigrad_assuseatt_uix | 16 | moodle_customer.asu.assignment,moodle_customer.asu.userid | 1 | Using index | |
| 1 | SIMPLE | f2 | ref | mdl_file_comfilconite_ix | mdl_file_comfilconite_ix | 604 | const,const | 891968 | Using where; Not exists | |
| 1 | SIMPLE | f3 | ref | mdl_file_comfilconite_ix | mdl_file_comfilconite_ix | 604 | const,const | 2960338 | Using index condition; Using where | |
+------+-------------+-------+--------+------------------------------------------------------------------------------------------------------------+----------------------------+---------+-----------------------------------------------------+----------+------------------------------------+
|
We're finding that these tasks never complete, and just start running on top of each other due to the extreme processing time required by the database to gather this result set.
I believe I have an updated query that pulls some additional information from the context table allowing joins to be more performant.