MDL-83628 message: message_provider_uninstall slow

This function was slow because using case-insensitive LIKE on the large
user_preferences table means that Postgres does not use its index and
has to sequential-scan the table.
This commit is contained in:
sam marshall
2025-04-24 13:04:53 +01:00
parent c576443111
commit f6c1e82a52
+1 -1
View File
@@ -716,7 +716,7 @@ function message_provider_uninstall($component) {
$transaction = $DB->start_delegated_transaction();
$DB->delete_records('message_providers', array('component' => $component));
$DB->delete_records_select('config_plugins', "plugin = 'message' AND ".$DB->sql_like('name', '?', false), array("%_provider_{$component}_%"));
$DB->delete_records_select('user_preferences', $DB->sql_like('name', '?', false), array("message_provider_{$component}_%"));
$DB->delete_records_select('user_preferences', $DB->sql_like('name', '?'), ["message_provider_{$component}_%"]);
$transaction->allow_commit();
// Purge all messaging settings from the caches. They are stored by plugin so we have to clear all message settings.
cache_helper::invalidate_by_definition('core', 'config', array(), 'message');