odoo/odoo#185750

Created by fw-bot
Merged at 15af1eff52818ef3726226ee1e39ab9fa13b3b68

Statuses:

label
odoo-dev:master-16.0-opw-4160576-avd-1gB9-fw
head
2b3eb2d3e450f06d4e1c0329975c3534dfaf8a25
merged
7 months ago by Aurélien van Delft (avd)
odoo/odoo
16.0 #179359
17.0 #184963
saas-17.2 #184988
saas-17.4 #184998
18.0 #185740
saas-18.1
saas-18.2
saas-18.3
master #185750

[FW][PERF] stock: lower limit for report_stock_quantity

Currently the report_stock_quantity view third UNION ALL does a generate_series between the moves date and now() in case the move is not in done.

This can lead to significant slowdowns when querying the view in case some databases have old moves not in done, cancel, draft. In that case, the report will generate a row for each day between the move.date and now(), leading to thousands of rows for 1 stock.move.

To alleviate that, this commit uses the report_period as a lower bound. This greatly reduces the number of rows generated by the third UNION ALL without losing forecasted accuracy since the moves are not in done.

speedup

In a v17 database where all_sm returns 600 000 rows, querying the report_stock_quantity view goes from 20s -> 7s.


I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr

Forward-Port-Of: #184998
Forward-Port-Of: #179359