-
Improvement
-
Resolution: Fixed
-
Major
-
2.1.3, 2.2.1
-
MySQL
-
MOODLE_21_STABLE, MOODLE_22_STABLE
-
MOODLE_23_STABLE
-
w19_
MDL-31617_m23_coursesortorder -
-
In function fix_course_sortorder(), this query is a bottleneck on big instances:
// categories having courses with sortorder duplicates or having gaps in sortorder
|
$sql = "SELECT DISTINCT c1.category AS id , cc.sortorder
|
FROM {course} c1
|
JOIN {course} c2 ON c1.sortorder = c2.sortorder
|
JOIN {course_categories} cc ON (c1.category = cc.id)
|
WHERE c1.id <> c2.id";
|
$fixcategories = $DB->get_records_sql($sql);
|
In one of our Moodles that has over 20k courses, and on my sandbox it takes over 30 seconds to execute. The fix for MySQL is to simply add index on course.sortorder, which brings the execution of the query down to split of a second.
- blocks
-
MDL-32659 Unusually costly mdl_course query on every page load under Moodle 2.2 using PostgreSQL
-
- Closed
-
- has been marked as being related by
-
MDL-31870 Time out error when creating a course category on a site with lots of courses
-
- Closed
-
- will help resolve
-
MDL-31782 saving course settings is suspiciously slow when you have lots of courses
-
- Closed
-