mirror of
https://github.com/zulip/zulip.git
synced 2025-11-08 16:01:58 +00:00
Increase MySQL batch size to 10,000.
This saves 30 seconds in populate_db runtime on MySQL. (imported from commit 7fe483bf5f32cfa3d09db8ad7a9be79bd0a2a271)
This commit is contained in:
@@ -5,7 +5,7 @@ def batch_bulk_create(cls, cls_list, batch_size=150):
|
|||||||
if "sqlite" not in settings.DATABASES["default"]["ENGINE"]:
|
if "sqlite" not in settings.DATABASES["default"]["ENGINE"]:
|
||||||
# We don't need a low batch size with mysql, but we do need
|
# We don't need a low batch size with mysql, but we do need
|
||||||
# one to avoid "MySQL Server has gone away" errors
|
# one to avoid "MySQL Server has gone away" errors
|
||||||
batch_size = 2000
|
batch_size = 10000
|
||||||
while len(cls_list) > 0:
|
while len(cls_list) > 0:
|
||||||
current_batch = cls_list[0:batch_size]
|
current_batch = cls_list[0:batch_size]
|
||||||
cls.objects.bulk_create(current_batch)
|
cls.objects.bulk_create(current_batch)
|
||||||
|
|||||||
Reference in New Issue
Block a user