Use CTE for currency rate
In the last patch version for #9665 (closed), I found that I could optimize the query by using a CTE for the currency rate instead of joining against the query directly. You can find the differences by comparing both query plans: https://explain.dalibo.com/plan/paL vs https://explain.dalibo.com/plan/sgd As sale reporting is based on the same design, we should get similar improvement by also using a CTE for the currency rate.