odoo/odoo#200877

Created by fw-bot
Merged at 9628011109180b0d32dc08ac5d365e2828245aca

Statuses:

label
odoo-dev:master-saas-17.4-report-stock-quantity-quadratic-time-join-slow-etvi-421345-fw
head
23a9460d995998562f57b2ade8d5985b7d887611
merged
8 months ago by Vincent Ethan
odoo/odoo
saas-17.4 #200682
18.0 #200760
saas-18.1 #200788
saas-18.2 #200811
saas-18.3
saas-18.4
19.0
master #200877

[FW][PERF] stock: CASE in JOIN on dest/final_id

We need to use either location_dest_id or location_final_id in the stock quantity report. Commit e16b3bc adds the logic for this but implements it using a CASE in the JOIN which the planner selects a nested loop based plan to accomplish (quadratic time).

Change it here to a boolean expression which can be better optimized by the query planner.

Forward-Port-Of: #200682