From e9f7c4a4b271c1b640639b9feca6430eddf5aee9 Mon Sep 17 00:00:00 2001 From: Adam Olley Date: Thu, 2 Jun 2016 15:42:16 +0930 Subject: [PATCH] MDL-54797 course: Add indexed field to condition of delete query Deleting records from the course_completion_criteria table goes much faster when we include the indexed course field in the delete query. --- course/lib.php | 1 + 1 file changed, 1 insertion(+) diff --git a/course/lib.php b/course/lib.php index dddbf4544f3..994b37ef4eb 100644 --- a/course/lib.php +++ b/course/lib.php @@ -1772,6 +1772,7 @@ function course_delete_module($cmid) { // very quick on an empty table). $DB->delete_records('course_modules_completion', array('coursemoduleid' => $cm->id)); $DB->delete_records('course_completion_criteria', array('moduleinstance' => $cm->id, + 'course' => $cm->course, 'criteriatype' => COMPLETION_CRITERIA_TYPE_ACTIVITY)); // Delete all tag instances associated with the instance of this module. -- 2.43.0