From ca7acae65372fc46a7266cfbd41abfda3bc16cbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 30 Dec 2022 13:59:04 +0100 Subject: [PATCH] Add index on id and lift It can be used by the database to optimize the search of rules. Closes #11843 --- .../sale.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/modules/sale_product_recommendation_association_rule/sale.py b/modules/sale_product_recommendation_association_rule/sale.py index b149d4537c..071eb0495d 100644 --- a/modules/sale_product_recommendation_association_rule/sale.py +++ b/modules/sale_product_recommendation_association_rule/sale.py @@ -129,11 +129,16 @@ class ProductAssociationRule(ModelSQL, ModelView): def __setup__(cls): super().__setup__() t = cls.__table__() - cls._sql_indexes.add( - Index( - t, - (t.lift, Index.Range(order='DESC')), - (t.conviction, Index.Range(order='ASC')))) + cls._sql_indexes.update({ + Index( + t, + (t.lift, Index.Range(order='DESC')), + (t.conviction, Index.Range(order='ASC'))), + Index( + t, + (t.id, Index.Range()), + (t.lift, Index.Range(order='DESC'))), + }) def get_product_names(self, name): return ', '.join(