Skip to content
Snippets Groups Projects
Commit e00dce5e authored by Nicolas Seinlet's avatar Nicolas Seinlet Committed by Thibault Delavallée
Browse files

[IMP] mail: improve blacklist search performance


When the blacklist table is filled with multiple thousands of records
searching the `is_blacklisted` field leads to a domain like
`[('id', 'in', [thousands_of_ids])]`. This can create a multiple megabytes
sql query.

Using inselect allows to avoid that issue.

Task-3328210

closes odoo/odoo#135458

Related: odoo/enterprise#47393
Signed-off-by: default avatarThibault Delavallee (tde) <tde@openerp.com>
parent c4b5148b
No related branches found
No related tags found
No related merge requests found
......@@ -76,11 +76,11 @@ class MailBlackListMixin(models.AbstractModel):
ON m.email_normalized = bl.email AND bl.active
WHERE bl.id IS NULL
"""
self._cr.execute(query % self._table)
self._cr.execute((query + " FETCH FIRST ROW ONLY") % self._table)
res = self._cr.fetchall()
if not res:
return [(0, '=', 1)]
return [('id', 'in', [r[0] for r in res])]
return [('id', 'inselect', (query % self._table, []))]
@api.depends('email_normalized')
def _compute_is_blacklisted(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment