Use .iterator() idiom in init_tags

to avoid loading all events into memory before looping over them

There's some warnings in the docs about SQLite and iterators, but
I don't think those apply, for one because we don't write to the
events: https://docs.djangoproject.com/en/5.1/ref/databases/#sqlite-isolation
This commit is contained in:
Klaas van Schelven
2025-02-27 14:54:08 +01:00
parent ab961d81c1
commit 0d4d95defd

View File

@@ -19,7 +19,7 @@ class Command(BaseCommand):
t0 = time.time()
try:
for i, event in enumerate(Event.objects.all()):
for i, event in enumerate(Event.objects.all().iterator()):
# transaction per event: allows for interrupting the process without losing all progress; also allows
# for your server to remain responsive during the process
with immediate_atomic():