[FIX] product: add index on pricelist items for better perf
With a high number of pricelist items (8.000.000 in the observed case), the SQL request performed in `_price_rule_get_multi` took a significant time (>3000ms) to be executed without an index on the `pricelist_id`. opw-670153
This commit is contained in:
@@ -269,6 +269,11 @@ class product_pricelist_item(osv.osv):
|
||||
_description = "Pricelist item"
|
||||
_order = "applied_on, min_quantity desc"
|
||||
|
||||
def init(self, cr):
|
||||
cr.execute('SELECT indexname FROM pg_indexes WHERE indexname = %s', ('product_pricelist_item_pricelist_id_index',))
|
||||
if not cr.fetchone():
|
||||
cr.execute('CREATE INDEX product_pricelist_item_pricelist_id_index ON product_pricelist_item (pricelist_id)')
|
||||
|
||||
def _check_recursion(self, cr, uid, ids, context=None):
|
||||
for obj_list in self.browse(cr, uid, ids, context=context):
|
||||
if obj_list.base == 'pricelist':
|
||||
|
||||
Reference in New Issue
Block a user