From 52ae580ad691fd78083b41b957c83fd3c35a477d Mon Sep 17 00:00:00 2001 From: Laurent David Date: Thu, 28 Jul 2022 16:14:48 -0400 Subject: [PATCH] MDL-75227 mod_bigbluebuttonbn: Optimize User logs retrieval * When loading a course with the Recent Activity block the bigbluebuttonbn_print_recent_activity takes too much time to load the logs. Using the courseid (index of log table) improves the time taken by the query. --- mod/bigbluebuttonbn/classes/logger.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mod/bigbluebuttonbn/classes/logger.php b/mod/bigbluebuttonbn/classes/logger.php index 90bb5e55066..e0122602e29 100644 --- a/mod/bigbluebuttonbn/classes/logger.php +++ b/mod/bigbluebuttonbn/classes/logger.php @@ -177,6 +177,7 @@ EOF; [$insql, $params] = $DB->get_in_or_equal($filters, SQL_PARAMS_NAMED); $wheres = []; $wheres['bigbluebuttonbnid'] = '= :instanceid'; + $wheres['courseid'] = '= :courseid'; // This speeds up the requests masively as courseid is an index. if ($timestart) { $wheres['timecreated'] = ' > :timestart'; $params['timestart'] = $timestart; @@ -186,6 +187,7 @@ EOF; $params['userid'] = $userid; } $params['instanceid'] = $instance->get_instance_id(); + $params['courseid'] = $instance->get_course_id(); $wheres['log'] = " $insql"; $wheresqls = []; foreach ($wheres as $key => $val) {