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

Queries for deleting messages are not optimal on mariadb/mysql

    XMLWordPrintable

Details

    • Improvement
    • Resolution: Unresolved
    • Minor
    • None
    • 3.9.2
    • None
    • 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

              darko.miletic Darko Miletic
              darko.miletic Darko Miletic
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated: