-
Bug
-
Resolution: Duplicate
-
Major
-
None
-
2.3.2
-
MOODLE_23_STABLE
There's been a couple of issues around performance of the course_overview block reported recently (e.g. http://tracker.moodle.org/browse/MDL-34785) but I couldn't see one for this specific issue.
If the sectioncache or modinfo fields for a course are initially empty when viewing the course overview block then rebuild_course_cache($course->id) in the constructor for course_modinfo (lib/modinfolib.php) is invoked multiple times.. not ideal given how expensive this can be especially for larger sites, causing 10's of thousands of DB calls.
The problem looks to be:
1) blocks/course_overview/block_course_overview.php retrieves all courses including sectioncache and modinfo and then calls print_overview(..) on those courses
2) print_overview(..) in course/lib.php invokes modname_print_overview(..), e.g. assignment_print_overview for each module type
3) assignment_print_overview for example calls get_all_instances_in_courses which invokes get_fast_modinfo, passing in each course record that was previously retrieved from the database in 1.
4) get_fast_mod_info creates a new instance of the course_modinfo class. The constructor checks the course record to see if sectioncache and modinfo are set, if they're not they are rebuilt.
After get_fast_mod_info has run for at least the first module type for a course it shouldn't need to rebuild the cache a second time...