-
- Downloads
[FIX] hr_work_entry: improve query and add indices
The query below https://github.com/odoo/odoo/blob/81497125d8100c6bdd2dc30434232a88a419a3e3/addons/hr_work_entry/models/hr_work_entry.py#L92-L115 has bad performance without the bespoken indices on `date_start` and `date_stop`. We can speed it up more with an index on `employee_id`. This is not enough for DBs with many work entries (500K+), specially during upgrades. Here we optimize the query to take into account only the work entries being modified. This issue was observed during an upgrade saas~12.3->13.0 where the payslip recomputation never ends due to the increased amount of hr work entries created. Note how the first 1K payslips are processed in 1 hour (~16 payslips per minute), while the latest 3 (before the upgrade was killed) took 1 min. ``` 2021-11-02 21:05:44,403 2229 INFO db_42897 odoo.modules.migration: module hr_payroll: Running migration [$saas~12.4.1.0] end-compute-amount 2021-11-02 21:06:44,577 2229 INFO db_42897 odoo.upgrade: [1.61%] 1120/69635 payslip processed in 0:01:00.036716 (total estimated time: 1:02:12.729213) 2021-11-02 21:07:44,602 2229 INFO db_42897 odoo.upgrade: [2.66%] 1853/69635 payslip processed in 0:02:00.062972 (total estimated time: 1:15:11.918540) ... 2021-11-05 09:59:46,565 2229 INFO db_42897 odoo.upgrade: [47.95%] 33390/69635 payslip processed in 2 days, 12:54:02.025479 (total estimated time: 5 days, 7:00:30.261882) 2021-11-05 10:01:04,990 2229 INFO db_42897 odoo.upgrade: [47.95%] 33393/69635 payslip processed in 2 days, 12:55:20.450549 (total estimated time: 5 days, 7:02:32.725840) ``` opw-2672031 closes odoo/odoo#80202 Signed-off-by:Nicolas Seinlet (nse) <nse@odoo.com>
Loading
Please register or sign in to comment