Specify batch size for bulk_update()
This commit is contained in:
parent
d34b9ee00e
commit
88aa3a4e19
|
|
@ -13,7 +13,7 @@ def update_parents_children(prefix):
|
|||
parents = prefix.get_parents(include_self=True).annotate_hierarchy()
|
||||
for parent in parents:
|
||||
parent._children = parent.hierarchy_children
|
||||
Prefix.objects.bulk_update(parents, ['_children'])
|
||||
Prefix.objects.bulk_update(parents, ['_children'], batch_size=100)
|
||||
|
||||
|
||||
def update_children_depth(prefix):
|
||||
|
|
@ -23,7 +23,7 @@ def update_children_depth(prefix):
|
|||
children = prefix.get_children(include_self=True).annotate_hierarchy()
|
||||
for child in children:
|
||||
child._depth = child.hierarchy_depth
|
||||
Prefix.objects.bulk_update(children, ['_depth'])
|
||||
Prefix.objects.bulk_update(children, ['_depth'], batch_size=100)
|
||||
|
||||
|
||||
@receiver(post_save, sender=Prefix)
|
||||
|
|
|
|||
Loading…
Reference in New Issue