Skip to content
Snippets Groups Projects
Commit 05855b6b authored by Victor Piryns (pivi)'s avatar Victor Piryns (pivi)
Browse files

[FIX] project: speed up name_search of tags on a task


Description:
The pop-up that shows suggestions when adding a tag on a task is
really slow (300~500ms per request on prod).

Cause:
`project.tag` has an override of `_name_search()`, which adds a
domain of the form
```python
['|', ('task_ids.project_id', '=', project_id),
 ('project_ids', 'in', project_id)]
```
which is expensive to compute.

Functional requirements:
- Suggest tags of the "project" first (those that are on tasks in the
  same project), then all the rest.
- Tag's name should be sorted alphabetically per result set (tags on tasks of
project first, sorted alphabetically, then all other tags, sorted
alphabetically)

Solution:
Construct a custom query that makes use of CTE and `UNION ALL` to sort
only on a subsets of the tags to speed up. Also `UNION ALL` with a
`LIMIT` is lazy evaluated, so we gain on speed of all tags are comming
from tags on tasks in the current project.

Affected version:
- 16.0
- saas-16.1
- master

perf-3209468

closes odoo/odoo#114318

Signed-off-by: default avatarXavier Bol (xbo) <xbo@odoo.com>
parent 93f6bf8d
No related branches found
No related tags found
No related merge requests found
Loading
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