From a09dadd2531543b9cc7583b4f5e887a8c39819b9 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Wed, 23 Jul 2014 23:31:36 +0200 Subject: [PATCH] [FIX] share: reduce risk of slowdowns during res.groups changes Databases with thousands of users would experience poor performance during any change to a group during an update/install, caused by the prefetching of all database users when the browse cache contains most of the groups in the system. --- addons/share/res_users.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/share/res_users.py b/addons/share/res_users.py index 9c9ae0034e2..56a3887b52a 100644 --- a/addons/share/res_users.py +++ b/addons/share/res_users.py @@ -33,7 +33,10 @@ class res_users(osv.osv): def _get_users_from_group(self, cr, uid, ids, context=None): result = set() - for group in self.pool['res.groups'].browse(cr, uid, ids, context=context): + groups = self.pool['res.groups'].browse(cr, uid, ids, context=context) + # Clear cache to avoid perf degradation on databases with thousands of users + groups.invalidate_cache() + for group in groups: result.update(user.id for user in group.users) return list(result)