Details
-
Bug
-
Resolution: Fixed
-
Major
-
2.9.4, 3.7.5, 3.8.2, 3.9
-
MOODLE_29_STABLE, MOODLE_37_STABLE, MOODLE_38_STABLE, MOODLE_39_STABLE
-
MOODLE_37_STABLE, MOODLE_38_STABLE
-
MDL-52904-master -
Description
I have a problem, the completion cron task run on slow mode when system has more than 100k users.
Relates to completion_cron_mark_started function in file /completion/cron.php
I suspect a problem in this query inside cron file.
RETURN MORE THAN 200 MILLION ROWS
SELECT
|
c.id AS course, |
u.id AS userid, |
crc.id AS completionid, |
ue.timestart AS timeenrolled, |
ue.timecreated
|
FROM
|
{user} u |
INNER JOIN |
{user_enrolments} ue
|
ON ue.userid = u.id |
INNER JOIN |
{enrol} e
|
ON e.id = ue.enrolid |
INNER JOIN |
{course} c
|
ON c.id = e.courseid |
INNER JOIN |
{role_assignments} ra
|
ON ra.userid = u.id |
LEFT JOIN |
{course_completions} crc
|
ON crc.course = c.id |
AND crc.userid = u.id |
WHERE
|
c.enablecompletion = 1
|
AND crc.timeenrolled IS NULL |
AND ue.status = 0 |
AND e.status = 0 |
AND u.deleted = 0 |
AND ue.timestart < ? |
AND (ue.timeend > ? OR ue.timeend = 0) |
$roles
|
ORDER BY |
course,
|
userid
|