Skip to content

Commit 9757242

Browse files
committed
[IMP] models: explode the delete of ir records
The delete of records in parallel was problematic before upgrade-util/pull/49 but it can offer a better time performance on large tables. Using a bucket size of 1000 instead of the default 10000 to reduce the chances of conflicts closes #206 Signed-off-by: Christophe Simonis (chs) <[email protected]>
1 parent 4cf34a4 commit 9757242

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/util/models.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -583,8 +583,10 @@ def remove_inherit_from_model(cr, model, inherit, keep=(), skip_inherit=(), with
583583
and not ir.company_dependent_comodel
584584
]
585585
for ir in irs:
586-
query = format_query(cr, "DELETE FROM {} WHERE ({})", ir.table, sql.SQL(ir.model_filter()))
587-
cr.execute(query, [model]) # cannot be executed in parallel. See git blame.
586+
query = cr.mogrify(
587+
format_query(cr, "DELETE FROM {} WHERE ({})", ir.table, sql.SQL(ir.model_filter())), [model]
588+
).decode()
589+
explode_execute(cr, query, table=table, bucket_size=1000)
588590
remove_field(cr, model, field, skip_inherit="*") # inherits will be removed by the recursive call.
589591

590592
# down on inherits of `model`

0 commit comments

Comments
 (0)