Details
-
Type:
Bug
-
Status: Closed
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: 3.4.1
-
Fix Version/s: 3.4.3
-
Component/s: Calendar, Performance
-
Labels:
-
Testing Instructions:
-
Affected Branches:MOODLE_34_STABLE
-
Fixed Branches:MOODLE_34_STABLE
-
Pull from Repository:
-
Pull Master Branch:
MDL-61519-master -
Pull Master Diff URL:
Description
The calendar currently has several calls to \coursecat::get_all() which is especially inefficient when you have a lot of course categories (more than CONTEXT_CACHE_MAX_SIZE that is 2500 currently).
calendar_information->set_sources and core_calendar_external->get_calendar_events even have nested iterations through all categories, which doesn't scale well.
We have about 3000 course categories and loading the dashboard takes about 8 seconds and more than 10000 db queries are executed.
These are the backtraces for the queries:
* line 776 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->query_end()
|
* line 1571 of /lib/dml/moodle_database.php: call to pgsql_native_moodle_database->get_records_sql()
|
* line 1543 of /lib/dml/moodle_database.php: call to moodle_database->get_record_sql()
|
* line 1522 of /lib/dml/moodle_database.php: call to moodle_database->get_record_select()
|
* line 6192 of /lib/accesslib.php: call to moodle_database->get_record()
|
* line 2462 of /lib/coursecatlib.php: call to context_coursecat::instance()
|
* line 2411 of /lib/coursecatlib.php: call to coursecat->get_context()
|
* line 72 of /cache/lib.php: call to coursecat->prepare_to_cache()
|
* line 711 of /cache/classes/loaders.php: call to cache_cached_object->__construct()
|
* line 330 of /lib/coursecatlib.php: call to cache->set_many()
|
* line 1181 of /calendar/lib.php: call to coursecat::get_all()
|
* line 1079 of /calendar/lib.php: call to calendar_information->set_sources()
|
* line 52 of /blocks/calendar_upcoming/block_calendar_upcoming.php: call to calendar_information::create()
|
* line 776 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->query_end()
|
* line 1571 of /lib/dml/moodle_database.php: call to pgsql_native_moodle_database->get_records_sql()
|
* line 1543 of /lib/dml/moodle_database.php: call to moodle_database->get_record_sql()
|
* line 1522 of /lib/dml/moodle_database.php: call to moodle_database->get_record_select()
|
* line 6192 of /lib/accesslib.php: call to moodle_database->get_record()
|
* line 2462 of /lib/coursecatlib.php: call to context_coursecat::instance()
|
* line 1182 of /calendar/lib.php: call to coursecat->get_context()
|
* line 1079 of /calendar/lib.php: call to calendar_information->set_sources()
|
* line 52 of /blocks/calendar_upcoming/block_calendar_upcoming.php: call to calendar_information::create()
|
When you have so many categories, iterating through all categories constantly fills up the context cache. When you want to access a category context, the cache entry has already been discarded.