-
Improvement
-
Resolution: Unresolved
-
Minor
-
None
-
3.11.13, 4.1.2
-
MOODLE_311_STABLE, MOODLE_401_STABLE
-
MDL-77641-optimize-sql-quiz-attempts
-
This sql has some bottlenecks which can be resolved with some easy tweaks
2023-02-28 11:57:41 Execute scheduled task: Recalculate question statistics (quiz_statistics\task\recalculate)
2023-02-28 11:57:41 ... started 11:57:41. Current memory use 4.3 MB.
2023-02-28 12:01:50 ... used 1 dbqueries
2023-02-28 12:01:50 ... used 249.07332205772 seconds
2023-02-28 12:01:50 Scheduled task failed: Recalculate question statistics (quiz_statistics\task\recalculate),Error reading from database
2023-02-28 12:01:50 Debug info:
2023-02-28 12:01:50 The table '/rdsdbdata/tmp/#sql499f_666d3_0' is full
2023-02-28 12:01:50
2023-02-28 12:01:50 SELECT q.id AS quizid,
2023-02-28 12:01:50 q.name AS quizname,
2023-02-28 12:01:50 c.id AS courseid,
2023-02-28 12:01:50 c.shortname AS courseshortname,
2023-02-28 12:01:50 MAX(qa.timefinish) AS mostrecentattempttime,
2023-02-28 12:01:50 COUNT(1) AS numberofattempts
2023-02-28 12:01:50 FROM mdl_quiz_attempts qa
2023-02-28 12:01:50 JOIN mdl_quiz q ON q.id = qa.quiz
2023-02-28 12:01:50 JOIN mdl_course c ON c.id = q.course
2023-02-28 12:01:50 WHERE qa.preview = 0
2023-02-28 12:01:50 AND qa.state = ?
2023-02-28 12:01:50 GROUP BY q.id, q.name, c.id, c.shortname
2023-02-28 12:01:50
2023-02-28 12:01:50 [array (
2023-02-28 12:01:50 0 => 'finished',
2023-02-28 12:01:50 )]
2023-02-28 12:01:50 Backtrace:
2023-02-28 12:01:50 * line 291 of /lib/dml/moodle_read_slave_trait.php: call to moodle_database->query_end()
2023-02-28 12:01:50 * line 1273 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->query_end()
2023-02-28 12:01:50 * line 72 of /mod/quiz/report/statistics/classes/task/recalculate.php: call to mysqli_native_moodle_database->get_records_sql()
2023-02-28 12:01:50 * line 253 of /lib/cronlib.php: call to quiz_statistics\task\recalculate->execute()
: 2023-02-28 12:01:50 * line 167 of /admin/cli/scheduled_task.php: call to cron_run_inner_scheduled_task()