[IMP] mail: improve get_mention_suggestion performance
"Order by" makes the query really slow. On a database with 1000000 partner and 10000 user, this query goes from 5.5s to 600ms. Once cached by Pgsql it goes down below 100ms. task-2982401 closes odoo/odoo#118198 Signed-off-by: Sébastien Theys (seb) <seb@odoo.com> Co-authored-by: Sébastien Theys <seb@odoo.com>
This commit is contained in:
co-authored by
Sébastien Theys
parent
cedc968f22
commit
611069fb65
@@ -335,7 +335,11 @@ class Partner(models.Model):
|
||||
remaining_limit = limit - len(partners)
|
||||
if remaining_limit <= 0:
|
||||
break
|
||||
partners |= self.search(expression.AND([[('id', 'not in', partners.ids)], domain]), limit=remaining_limit)
|
||||
# We are using _search to avoid the default order that is
|
||||
# automatically added by the search method. "Order by" makes the query
|
||||
# really slow.
|
||||
query = self._search(expression.AND([[('id', 'not in', partners.ids)], domain]), limit=remaining_limit)
|
||||
partners |= self.browse(query)
|
||||
partners_format = partners.mail_partner_format()
|
||||
if channel_id:
|
||||
member_by_partner = {member.partner_id: member for member in self.env['mail.channel.member'].search([('channel_id', '=', channel_id), ('partner_id', 'in', partners.ids)])}
|
||||
|
||||
Reference in New Issue
Block a user