Skip to content
Snippets Groups Projects
Commit 2813dea3 authored by Stanislas Sobieski's avatar Stanislas Sobieski Committed by Arnold Moyaux
Browse files

[FIX] purchase_stock: add index on created_purchase_line_id of stock.move


EXPLAIN ANALYZE SELECT "stock_move".id
FROM "stock_move"
WHERE ("stock_move"."created_purchase_line_id" in (24065, 24066, 24081, 24082, 24083, 24084, 24085, 24086, 24087, 24088, 24089, 24090, 24091, 24092, 24093, 26121, 26487)) and ("stock_move"."company_id" in (1))
ORDER BY "stock_move"."sequence" ,"stock_move"."id" ;
Goes from 2231.021 ms to 1ms on a database with 2.800.000 stock_move.

closes odoo/odoo#105136

X-original-commit: d7ea47f4
Signed-off-by: default avatarArnold Moyaux (arm) <arm@odoo.com>
parent 6a941201
No related branches found
No related tags found
No related merge requests found
......@@ -19,7 +19,7 @@ class StockMove(models.Model):
purchase_line_id = fields.Many2one('purchase.order.line',
'Purchase Order Line', ondelete='set null', index=True, readonly=True)
created_purchase_line_id = fields.Many2one('purchase.order.line',
'Created Purchase Order Line', ondelete='set null', readonly=True, copy=False)
'Created Purchase Order Line', ondelete='set null', readonly=True, copy=False, index=True)
@api.model
def _prepare_merge_moves_distinct_fields(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment