changeset b63c91efe03a in trytond:default
details: https://hg.tryton.org/trytond?cmd=changeset&node=b63c91efe03a
description:
        Add implicit join clause to subquery of where clause on Many2One

        This modify the complexity of the SubPlan from O(n^2) to O(n log(n)) 
thanks to
        the index on the primary key.

        issue11486
        review415121003
diffstat:

 trytond/model/fields/many2one.py |  2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diffs (12 lines):

diff -r 180997544b2e -r b63c91efe03a trytond/model/fields/many2one.py
--- a/trytond/model/fields/many2one.py  Sun Jul 17 23:52:44 2022 +0200
+++ b/trytond/model/fields/many2one.py  Mon Jul 18 00:18:41 2022 +0200
@@ -241,6 +241,8 @@
             # Used for Many2Many where clause
             if operator.endswith('where'):
                 query = Target.search(value, order=[], query=True)
+                target_id, = query.columns
+                query.where &= target_id == column
                 expression = column.in_(query)
                 if operator.startswith('not'):
                     return ~expression

Reply via email to