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

CLONE - Scheduled course backup runs full table scan on mdl_backup_log - possible regression.


    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Won't Fix
    • Affects Version/s: 1.8.4, 1.9
    • Fix Version/s: None
    • Component/s: Backup, Performance
    • Labels:
    • Environment:
      MySQL 5.0.22
    • Database:
    • Affected Branches:


      If scheduled course backups are enabled, cron.php calls schedule_backup_cron() whenever it runs. Line 36 of backup/backup_scheduled.php is

      $numofrec = count_records_select ("backup_log","time > $timeafter");

      This runs a full scan on mdl_backup_log, which can be a very large table depending on your site's log-retention policy. For example, we have cron.php scheduled to run every 5 minutes, and ~65,000 rows are read, simply to find out whether a backup task is currently running. The query takes around 4 seconds to complete. A workaround is to add an index to the table.

      ALTER TABLE mdl_backup_log ADD INDEX (time);

      This avoids the full table scan, and the query now completes in less than one hundredth of a second at our site. The drawback is that mdl_backup_log.MYI is now almost as big as mdl_backup_log.MYD I can't see any way of working around this issue in the PHP code.

        Gliffy Diagrams

          Issue Links


            leeb-syn Lee Bowyer created issue -
            leeb-syn Lee Bowyer made changes -
            Field Original Value New Value
            Link This issue has a clone MDL-13511 [ MDL-13511 ]
            skodak Petr Skoda made changes -
            Fix Version/s 1.9 [ 10190 ]
            dougiamas Martin Dougiamas made changes -
            Workflow jira [ 33011 ] MDL Workflow [ 45257 ]
            dougiamas Martin Dougiamas made changes -
            Workflow MDL Workflow [ 45257 ] MDL Full Workflow [ 73606 ]
            stronk7 Eloy Lafuente (stronk7) made changes -
            Assignee Eloy Lafuente (stronk7) [ stronk7 ]
            marina Marina Glancy made changes -
            Status Open [ 1 ] Closed [ 6 ]
            Resolution Won't Fix [ 2 ]


              • Votes:
                7 Vote for this issue
                6 Start watching this issue


                • Created: