Validating large pickings is much faster
Marking move lines as picked now uses two writes instead of one per move. On a picking with thousands of moves, 8 of the 8.2 seconds of button_validate went to re-running automation rules on each write.
Marking move lines as picked now uses two writes instead of one per move. On a picking with thousands of moves, 8 of the 8.2 seconds of button_validate went to re-running automation rules on each write.
| Branch | Pull request | Commit |
|---|---|---|
| 18.0 | odoo/odoo#290333 ↗ | 0cbb5f6663 ↗ |
| 19.0 | odoo/odoo#290352 ↗ | ac363afdb6 ↗ |
| 20.0 | odoo/odoo#290419 ↗ | 319d99537b ↗ |
[PERF] stock: batch stock.move.line writes in _inverse_picked
_inverse_picked wrote move.move_line_ids.picked one move at a time,
so button_validate on a picking with a couple thousand moves issued
one stock.move.line write per move. Each write re-triggers
base_automation's write hook, which recompiles every active rule's
domain on stock.move.line (safe_eval + compile, never cached).
Measured 8s of an 8.2s button_validate spent there on such a picking.
Split the moves into picked and not picked, then write each group's
move_line_ids once. Same end state, same records touched, two write
calls instead of one per move.
Benchmark, 2000 stock.move (1000 picked) + 2000 stock.move.line, one
active base_automation on_create_or_write rule on stock.move.line,
fresh 17.0 database with no demo data:
before: 3.001s, 4012 queries
after: 0.269s, 16 queries
11x faster, 250x fewer queries.