diff options
| author | Rémy Voet (ryv) <ryv@odoo.com> | 2021-01-05 10:48:12 +0000 |
|---|---|---|
| committer | Rémy Voet (ryv) <ryv@odoo.com> | 2021-01-21 13:52:32 +0000 |
| commit | a8dd0655b1e318a6940b5dd1708952043349de4e (patch) | |
| tree | 06e2e8b2b61ad7fc72c74268203d39039d0c2343 | |
| parent | 7dece58f1116e2ae669f7282bffb30cddf3d7624 (diff) | |
[FIX] stock: improve performance of `report.stock.quantity`
Use UNION ALL instead of UNION to let PostgreSQL
filter out rows before sorting and avoid Unique check.
Note that it shouldn't change the result because each 3 SELECT
doesn't have domain intersection.
Improve performance the `_get_orderpoint_action` and the Forecasted
Inventory.
Performance Gain:
With a large Database (5K products, 120K stock move, 20K quants, etc):
To open the Forecasted Inventory:
Before: 10.06 sec +- 0.02
After: 3.98 sec +- 0.07
task-2390516
| -rw-r--r-- | addons/stock/report/report_stock_quantity.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/addons/stock/report/report_stock_quantity.py b/addons/stock/report/report_stock_quantity.py index ea8a1472ac3..baaf490048f 100644 --- a/addons/stock/report/report_stock_quantity.py +++ b/addons/stock/report/report_stock_quantity.py @@ -58,7 +58,7 @@ WITH forecast_qty AS ( (whs.id IS NOT NULL OR whd.id IS NOT NULL) AND (whs.id IS NULL OR whd.id IS NULL OR whs.id != whd.id) AND m.state NOT IN ('cancel', 'draft', 'done') - UNION + UNION ALL SELECT -q.id as id, q.product_id, @@ -76,7 +76,7 @@ WITH forecast_qty AS ( WHERE (l.usage = 'internal' AND wh.id IS NOT NULL) OR l.usage = 'transit' - UNION + UNION ALL SELECT m.id, m.product_id, |
