Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-54797

Use indexed field when deleting completion criteria

    XMLWordPrintable

Details

    • MOODLE_29_STABLE, MOODLE_30_STABLE, MOODLE_31_STABLE
    • MOODLE_30_STABLE, MOODLE_31_STABLE
    • Hide

      Add a course module to a course
      Go to course completion and tick this activity as a requirement for course completion
      Verify rows were added to the course_completion_criteria table for it.
      Delete the course module from the course editing screen.
      Verify the rows in the course_completion_criteria table were deleted.

      Show
      Add a course module to a course Go to course completion and tick this activity as a requirement for course completion Verify rows were added to the course_completion_criteria table for it. Delete the course module from the course editing screen. Verify the rows in the course_completion_criteria table were deleted.

    Description

      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).

      Attachments

        Activity

          People

            aolley Adam Olley
            aolley Adam Olley
            Marina Glancy Marina Glancy
            Andrew Lyons Andrew Lyons
            Jun Pataleta Jun Pataleta
            Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Laurent David, Raquel Ortega, Sara Arjona (@sarjona), Matteo Scaramuccia, Andrew Lyons, Huong Nguyen, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze, Stevani Andolo
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              11/Jul/16