diff options
| author | Denis Ledoux <dle@odoo.com> | 2016-02-23 14:42:58 +0100 |
|---|---|---|
| committer | Denis Ledoux <dle@odoo.com> | 2016-02-23 14:46:41 +0100 |
| commit | 0cb3ed4e8ff7c53efa021c09e0aba91ebfa30a56 (patch) | |
| tree | 2f76d3c2e8e1ccafd5d1ee66daeb97ede33dc890 | |
| parent | 380a1fd544ef352b82224610c669ebb075199216 (diff) | |
[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
| -rw-r--r-- | addons/product/pricelist.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/addons/product/pricelist.py b/addons/product/pricelist.py index b23691384e9..d2d8e542e5f 100644 --- a/addons/product/pricelist.py +++ b/addons/product/pricelist.py @@ -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': |
