odoo/openerp/osv
Raphael Collet 3c2065c89d [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.
2017-04-06 15:59:50 +02:00
..
__init__.py [MERGE] new v8 api by rco 2014-07-06 17:05:41 +02:00
expression.py [FIX] expression: use sub-select when searching on many2many field 2017-04-06 15:59:50 +02:00
fields.py [FIX] fields: make [(5,)] with computed domain work (#13480) 2016-10-11 15:14:05 +02:00
orm.py [FIX] base: centralize custom data serialization for builtin types only 2016-02-02 22:42:31 +01:00
osv.py [MERGE] new v8 api by rco 2014-07-06 17:05:41 +02:00
query.py [REM] Deleted .apidoc lines. 2013-02-12 15:24:10 +01:00