I have a dumb simple loop
for alias in models.Alias.objects.all() :
alias.update_points()
but looking into the django QuerySet it seems to keep around a _result_cache
of all the previous results. This is eating Gigs and Gigs of my machine and eventually everything blows up.
How can I throw away all the stuff that I won't ever care about?
Use the queryset's iterator()
method to return the models in chunks, without populating the result cache:
for alias in models.Alias.objects.iterator() :
alias.update_points()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With