-
Bug
-
Resolution: Fixed
-
Minor
-
2.9.6, 3.0.4, 3.1
-
MOODLE_29_STABLE, MOODLE_30_STABLE, MOODLE_31_STABLE
-
MOODLE_30_STABLE, MOODLE_31_STABLE
-
Whenever a course module is deleted, it's related mdl_course_completion_criteria records are deleted. However, the conditions used in the DELETE statement don't use the indexed field in that table.
As such, on larger instances, the delete query can take awhile as it has to perform a scan of the whole table rather than on the index.
In one database with 20M rows in this table, the DELETE statement currently takes a full 2 seconds. This is masked from the end-user since it goes through an Ajax request to course/rest.php, but its obviously beneficial to make this easier on the database.
We already have the full course module record available to us where the delete is performed, so this change simply adds the course field to the delete query (which is an indexed field on that table).