No full partner scan for default recipients
The OdooBot check no longer counts partners on every call, and res.partner.email_normalized gets an index. Before, this was a full table scan once per invoice in the send wizard.
The OdooBot check no longer counts partners on every call, and res.partner.email_normalized gets an index. Before, this was a full table scan once per invoice in the send wizard.
| Branch | Pull request | Commit |
|---|---|---|
| 19.0 | odoo/odoo#295611 ↗ | 1d681666ab ↗ |
| 20.0 | odoo/odoo#296652 ↗ | b2e6d28098 ↗ |
[PERF] mail: skip OdooBot partner count for default recipients _message_get_default_recipients counted partners sharing OdooBot's email on every call to decide whether to ban it. res.partner.email_normalized is not indexed, so this is a full table scan, done e.g. once per invoice in the send wizard. Only run it when OdooBot's email is a candidate, and stop at the first match. Also add a btree index on res.partner.email_normalized: exact-match searches on it are common (find_or_create, recipient lookups). Benchmark: `_message_get_default_recipients` on one partner, 667k partners (median of 10 runs after warmup): | Version | SQL | ms | | --- | ---: | ---: | | Baseline | 5 | 97.6 | | PR | 3 | 1.0 | The skipped query alone takes ~250 ms on a 2M partners table.