[Django]-Django South migration leaks memory

3👍

I finally found the solution to my problem to avoid the caching in the QuerySet:

for tr in orm.TestResult.objects.iterator() :
    tr.software = ...

It was already asked on SO here:

Django : Iterate over a query set without cache

and the explanation in the Django docs:

http://docs.djangoproject.com/en/dev/ref/models/querysets/#iterator

👤Fabian

1👍

I think it’s better in your case to execute an sql upate query on all objects instead of updatnig records one by one. You can use execute with an sql statement like this one (I don’t know what database or data stucture you’re using, so this is just an example):

UPDATE TestResult
   SET TestResult.software = TestRun.software
  FROM TestResult JOIN TestRun
       ON TestResult.test_run_id = TestRun.id
👤manji

Leave a comment