-
Bug
-
Resolution: Unresolved
-
Minor
-
None
-
4.4.5
The message_provider_uninstall function is slow on large systems when using Postgres because of this line:
$DB->delete_records_select('user_preferences', $DB->sql_like('name', '?', false), array("message_provider_{$component}_%"));
|
The user_preferences table is a huge one on a system with lots of users, and although the 'name' field is indexed, this index doesn't appear to work for this call (at least in Postgres). Testing the database query involved, supposing you are deleting a plugin called local_frog, this would be roughly:
DELETE FROM mdl_user_preferences WHERE name ILIKE 'message_provider_local_frog_%'
|
This does a sequential scan and takes 12 seconds on my test system. Compare with:
DELETE FROM mdl_user_preferences WHERE name LIKE 'message_provider_local_frog_%'
|
This uses an index and completes instantly.
I can see no reason for the case-insensitivity (that's the 'false' parameter in the function) because these preferences are always added with lower case; nobody is going to add one called Message_Provider_local_frog_anything let alone message_provider_Local_Frog_anything.
So I propose removing the unnecessary case-insensitivity.
While 12 seconds may not be a lot, if you are uninstalling a number of plugins as part of a system upgrade (that's how we do it), it adds some rather pointless wasted time to the upgrade during which the system may be offline. Also:
- Even for a manual uninstall, the user experience is not great if it takes longer than needed.
- There are systems with an order of magnitude more users than ours so it could be a larger problem than 12 seconds.