diff --git a/lib/statslib.php b/lib/statslib.php index 1f72d683277..cad2252b7a0 100644 --- a/lib/statslib.php +++ b/lib/statslib.php @@ -259,6 +259,7 @@ function stats_cron_daily($maxdays=1) { $failed = true; break; } + $DB->update_temp_table_stats(); stats_progress('1'); @@ -385,6 +386,10 @@ function stats_cron_daily($maxdays=1) { $failed = true; break; } + // The steps up until this point, all add to {temp_stats_daily} and don't use new tables. + // There is no point updating statistics as they won't be used until the DELETE below. + $DB->update_temp_table_stats(); + stats_progress('7'); // Default frontpage role enrolments are all site users (not deleted) @@ -581,6 +586,7 @@ function stats_cron_daily($maxdays=1) { $failed = true; break; } + $DB->update_temp_table_stats(); stats_progress('15'); // How many view actions for guests or not-logged-in on frontpage @@ -1736,6 +1742,9 @@ function stats_temp_table_fill($timestart, $timeend) { $DB->execute($sql); + // We have just loaded all the temp tables, collect statistics for that. + $DB->update_temp_table_stats(); + return true; }