moodle-logstore_xapi
moodle-logstore_xapi copied to clipboard
Sites with large numbers of cohorts cannot load settings page, very poor performance
Description
- When installed on a site with a large number of cohorts, the plugin does not efficiently query them in the plugin settings, leading to very poor performance.
- Performance issues are across most site administration pages since moodle tries to re-query the settings
- The site in question has 165,652 cohorts
- The actual xapi settings page tries to make a checkbox for each cohort. This takes ages to load each checkbox and is more or less unusable, and likely will crash browsers on lower spec machines
Version
masterat416b92cfd672e02e1c92b5011ee6395bb95a5111on2022101800
Steps to reproduce the bug
- Enable profiling via site administration
- Create a large number of cohorts
- Profile the admin search page
https://site.com/admin/search.php?PROFILEME=1 - Check profiling run. In this site, the profiling run shows the following trace taking a large chunk of time:
admin_get_root
core\plugininfo\tool::load_settings
tool_log\plugininfo\logstore::load_settings
logstore_xapi_get_cohorts
The logstore_xapi_get_cohorts step takes ~10 seconds of execution time.
Expected behaviour
- Plugin does not impact site performance unnecessarily
Actual behaviour
- Admin page takes > 10 minutes to load.
- It tries to make a checkbox for each cohort. If I let it run, it tries to make 100,000+ checkboxes.
Server information
- Postgresql
- Moodle 4.1
- OS: Linux
I would recommend using recordsets to get the data, and refactoring the settings page to use a search/autocomplete box with multi select option.