Files
odoo_source/addons/mail
Victor Piryns (pivi) 967e0f7982 [PERF] mail: add missing index on alias_full_name
Description:
Since https://github.com/odoo/odoo/pull/76734, the new field
`alias_full_name` is used in addition to `alias_name` to search on
`mail.alias` and route emails in `message_route`. It's also used as
a search criteria in `_search_alias_email` on `mail.alias.mixin.
optional`. The issue is that the table `mail.alias` can grow quite
large, and only the old field `alias_name` has an index on it, which
may not be selective enough, forcing Seq.Scans on the table with
possibly millions of records. The impact is noticeable on
`message_route` which is a hot path for processing incoming emails.

Adding an index on `alias_full_name` allows PostgreSQL to do an
bitmap OR scan on the two indexes, considerably speeding up search
criteria that are a disjunction between `alias_name` and
`alias_full_name`.

Benchmark:
For domain
```python
[
    '&',
    ('alias_model_id', '!=', reply_model_id),
    '|',
    ('alias_full_name', 'in', email_to_list),
    '&', ('alias_name', 'in', email_to_localparts), ('alias_incoming_local', '=', True),
]
```
with test arguments, on a `mail.alias` table containing over 2M records.

|           | Before | After |
|-----------|--------|-------|
| Timing    | 696ms  | 1ms   |
| Buffer IO | 790MB  | 48KB  |

Specially impactful as those gains needs to be multiplied by the
frequency of the searches.

Reference:
task-3724844

closes odoo/odoo#156237

Signed-off-by: Olivier Dony (odo) <odo@odoo.com>
2024-03-05 16:48:17 +00:00
..
…

Odoo Enterprise Social Network

Connect with experts, follow what interests you, share documents and promote best practices with Odoo Enterprise Social Network. Get work done with effective collaboration across departments, geographies, documents and business applications. All of this while decreasing email overload.

Connect with experts

Next time you have a question for the marketing, sales, R&D or any other department, don't send an email blast-post the question to Odoo and get answers from the right persons.

Follow what interests you

Want to get informed about new product features, hot deals, bottlenecks in projects or any other event? Just follow what interests you to get the information you need what you need; no more, no less.

Get Things Done

You can process (not only read) the inbox and easily mark messages for future actions. Start feeling the pleasure of having an empty inbox every day; no more overload of information.

Promote best practices

Cut back on meetings and email chains by working together in groups of interests. Create a group to let people share files, discuss ideas, and vote to promote best practices.

Improve Access to Information and Expertise

Break down information silos. Search across your existing systems to find the answers and expertise you need to complete projects quickly.

Collaborate securely

Set the right security policy; public, private or on invitation only -- according to the information sensitivity.

A Twitter-like Network For My Company

Make every employee feel more connected and engaged with twitter-like features for your own company. Follow people, share best practices, 'like' top ideas, etc.