PerformanceHighlight of Weekly #005

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.

Versions19.020.0
ModulesDiscuss mail
AppProductivity

Pull requests and commits

BranchPull requestCommit
19.0odoo/odoo#295611 ↗1d681666ab ↗
20.0odoo/odoo#296652 ↗b2e6d28098 ↗

Commit message

[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.

My stack

Pick the versions and apps you run. Weekly digests, this week's table and All changes then show only what concerns you. Saved in this browser.

Versions
Apps
Modules