diff options
| author | Raphael Collet <rco@odoo.com> | 2017-04-05 10:48:39 +0200 |
|---|---|---|
| committer | Raphael Collet <rco@odoo.com> | 2017-04-06 15:59:50 +0200 |
| commit | 3c2065c89da757406f080d9252e2c3019c66e8c7 (patch) | |
| tree | 26f986c735539db97dd1e62bd6e3feecd0114a9d /addons/web/static/src/js/views/basic/basic_controller.js | |
| parent | 3128e8424373c545ea821c6d7e067f431f5b54d3 (diff) | |
[FIX] expression: use sub-select when searching on many2many field
Avoid pathological performance issue caused by injecting ids retrieved with
another query.
Consider a domain like `[('m2m', 'in', ids)]` on a many2many field. The
current implementation will perform the subquery:
SELECT m2m_id1 FROM m2m_table WHERE m2m_id2 IN (ids)
and inject its result into the main query as:
SELECT id FROM ... WHERE id IN (result_ids)
The latter may be very slow if `result_ids` is a huge list of ids.
The fix injects the first query into the main query as:
SELECT id FROM ... WHERE id IN (
SELECT m2m_id1 FROM m2m_table WHERE m2m_id2 IN (ids)
)
As a result, the database will typically JOIN both tables, and avoid generating
the whole list from the subquery.
Diffstat (limited to 'addons/web/static/src/js/views/basic/basic_controller.js')
0 files changed, 0 insertions, 0 deletions
