odoo/odoo#264754
Created by fw-bot
Statuses:
- legal/cla: Contributor License Agreement check
- ci/runbot: Odoo Test Suite
- ci/upgrade_enterprise: Test upgrades for enterprise master
- ci/template: (runtime 1960s)
- ci/style: Optional style check. Ignore it only if strictly necessary.
- ci/security: Required security check. Can only be ignored by security team.
- ci/l10n: (runtime 19s)
- ci/documentation: (runtime 976s)
- ci/design-theme: (runtime 3107s)
- label
- odoo-dev:saas-18.3-17.0-opw-6127513-macs-526995-fw
- head
- 99837a052fcda434e2aa21d34bc3ce439b37014d
- merged
- 3 weeks ago by Mackenzie Smith (macs)
| odoo/odoo | |
|---|---|
| 17.0 | #262321 |
| 18.0 | #264689 |
| saas-18.2 | #264712 |
| saas-18.3 | #264754 |
| saas-18.4 | #264793 |
| 19.0 | #264826 |
| saas-19.1 | #264848 |
| saas-19.2 | #265019 |
| saas-19.3 | #265058 |
| master | #265077 |
[PERF] mrp_subcontracting_purchase prevent unnecessary searches when computing lead_days
When computing qty_to_order 1-3 extra queries are made by get_lead_days(), which can cause performance issues when computing qty_to_order for a large number of orderpoints.
This commit aims to prevent these extra queries by returning early if the current product is not associated with a bom. The amount this commit speeds up the compute depends on how many of products passed into _get_lead_days() are associated with a bom.
qty_to_order is no longer a stored field after this commit: #159432
This benchmark was done in 18.0 on /stock.warehouse.orderpoint/search_panel_select_range. This call does not trigger the compute on all orderpoints in 17.0 as the field is stored but calling the compute directly on all orderpoints results in the same speed up as seen in 18.0.
| Orderpoints | % of products linked to a bom | Time before | Queries before | Time after | Queries After |
|---|---|---|---|---|---|
| 800 | 50% | 2.8s | 1570 | 2.3s | 818 |
| 8,000 | 0% | 28.2s | 16,698 | 15.3s | 242 |
| 8,000 | 25% | 29.6s | 16,833 | 19.2s | 4497 |
| 8,000 | 50% | 29.8s | 16,925 | 23.2s | 8693 |
| 8,000 | 75% | 31.6s | 16,949 | 27.6s | 12827 |
Forward-Port-Of: #262321