Skip to content

Commit 8ae6e53

Browse files
committed
[IMP] util.explode_{query_range,execute}
Allow to change the default bucket_size via an environment variable. On databases with a lot of records, a bigger bucket size can improve the upgrades. closes #271 Signed-off-by: Christophe Simonis (chs) <[email protected]>
1 parent e6f36d0 commit 8ae6e53

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/util/pg.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949

5050
ON_DELETE_ACTIONS = frozenset(("SET NULL", "CASCADE", "RESTRICT", "NO ACTION", "SET DEFAULT"))
5151
MAX_BUCKETS = int(os.getenv("MAX_BUCKETS", "150000"))
52+
DEFAULT_BUCKET_SIZE = int(os.getenv("BUCKET_SIZE", "10000"))
5253

5354

5455
class PGRegexp(str):
@@ -260,7 +261,7 @@ def explode_query(cr, query, alias=None, num_buckets=8, prefix=None):
260261
return [cr.mogrify(query, [num_buckets, index]).decode() for index in range(num_buckets)]
261262

262263

263-
def explode_query_range(cr, query, table, alias=None, bucket_size=10000, prefix=None):
264+
def explode_query_range(cr, query, table, alias=None, bucket_size=DEFAULT_BUCKET_SIZE, prefix=None):
264265
"""
265266
Explode a query to multiple queries that can be executed in parallel.
266267
@@ -336,7 +337,7 @@ def explode_query_range(cr, query, table, alias=None, bucket_size=10000, prefix=
336337
]
337338

338339

339-
def explode_execute(cr, query, table, alias=None, bucket_size=10000, logger=_logger):
340+
def explode_execute(cr, query, table, alias=None, bucket_size=DEFAULT_BUCKET_SIZE, logger=_logger):
340341
"""
341342
Execute a query in parallel.
342343

0 commit comments

Comments
 (0)