-
Bug
-
Resolution: Fixed
-
Minor
-
4.0.4
-
MOODLE_400_STABLE
-
MOODLE_400_STABLE
-
MDL-75738-master -
We are investigating poor performance of the update to Moodle 4.0 on our systems. One point is the tool_moodlenet upgrade 2021052501. This was applied in MDL-69240 to version 3.9, 3.10, but it still runs (again, presumably) on a Moodle 4.0 (from 3.11) upgrade because the version code in Moodle 3.11.8 is 2021051701. (Running it again should not do any harm, except for the performance cost, so this is OK.)
This upgrade contains the following SQL:
$sql = "SELECT u.*
|
FROM {user} u
|
WHERE u.moodlenetprofile IS NOT NULL";
|
Then it loops through the users, makes a change to moodlenetprofile and calls update_record.
There are 2 things wrong with this update:
1. As it selects all the user fields, it will update all fields of the record, when it only needs to update one.
but more fundamentally for us
2. We have about a million users where moodlenetprofile is NULL, but we also have 32,000 where it's an empty string.
We don't use moodlenet so this upgrade should be doing nothing; instead it's updating all fields of 32,000 user records one at a time, which takes a while.
Also 3. It should not do update_record if the clean_text didn't do anything.
HOWEVER all these performance details are pointless because there is now an admin step further down (2022021601) which (much more efficiently) sets the field to blank for all users anyway. So I propose just deleting the step, there is no point cleaning something we are about to blank.