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

Queries for deleting messages are not optimal on mariadb/mysql

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Deferred
    • Icon: Minor Minor
    • None
    • 3.9.2
    • None
    • MOODLE_39_STABLE

      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]
          );
      }
      
      

       

       

       

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

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.