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

Queries for deleting messages are not optimal on mariadb/mysql

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 3.9.2
    • Fix Version/s: None
    • Labels:
      None
    • Affected Branches:
      MOODLE_39_STABLE

      Description

      Methods \message_output_popup::cleanup_all_notifications and \message_output_popup::cleanup_read_notifications do not have fully optimized delete queries.

      This

      public function cleanup_all_notifications(int $notificationdeletetime): void {
          global $DB;
       
          $DB->delete_records_select('message_popup_notifications',
              'notificationid IN (SELECT id FROM {notifications} WHERE timecreated < ?)', [$notificationdeletetime]);
      }
      

      Should become this:

      public function cleanup_all_notifications(int $notificationdeletetime): void {
          global $DB;
       
          $DB->delete_records_select(
              'message_popup_notifications',
              'EXISTS (
                       SELECT id 
                         FROM {notifications}
                        WHERE timecreated < ? AND id = {message_popup_notifications}.notificationid
                       )',
              [$notificationdeletetime]
          );
      }
      
      

       

       

       

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              darko.miletic Darko Miletic
              Reporter:
              darko.miletic Darko Miletic
              Participants:
              Component watchers:
              Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated: