-
Improvement
-
Resolution: Fixed
-
Major
-
2.2.10, 2.3.7, 2.4.4, 2.5
-
MySQL
-
MOODLE_22_STABLE, MOODLE_23_STABLE, MOODLE_24_STABLE, MOODLE_25_STABLE
-
MOODLE_23_STABLE, MOODLE_24_STABLE, MOODLE_25_STABLE
-
w27_
MDL-40266_m26_arrayshift -
This issue was first discovered with the SCORM reports having slow page load times and the fix turned out to be a general performance increase for Moodle. We have about 40,000 Moodle users and our basic and interactions SCORM reports span hundreds of pages.
It turns out that the call to array_shift in function emulate_bound_params from the file lib/dml/mysqli_native_moodle_database.php is very slow when it needs to evaluate thousands of bound query parameters.
The function array_shift reindexes the array which is not necessary for the function emulate_bound_params, and is at least one reason for the bad performance.
Our fix involves using array_reverse and array_pop for faster bound parameter evaluations. These are the before and after stats for a SCORM report page load time:
Pre-patch page load time: 128.496265 secs
Post-patch page load time: 5.149125 secs
We only made the fix for mysqli.
Please take a look at these branches at http://github.com/timgus/moodle for the patch and unit tests (for M23 and up):
array_shift_fix_m22
array_shift_fix_m23
array_shift_fix_m24
array_shift_fix_m25
array_shift_fix_master
I've attached my xhprof run before and after the fix when viewing a SCORM report page.
- has been marked as being related by
-
MDL-40399 improve bound query emulation in ms sql drivers
- Closed