Просмотр исходного кода

Specify batch size for bulk_update()

jeremystretch 4 лет назад
Родитель
Сommit
88aa3a4e19
1 измененных файлов с 2 добавлено и 2 удалено
  1. 2 2
      netbox/ipam/signals.py

+ 2 - 2
netbox/ipam/signals.py

@@ -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)