1

I have a django model which has a load of relatively small fields and then one kinda huge one. Let's say something like this:

class MyModel(models.Model):

thing = models.ForeignKey('Thing')
egg = models.TextField()
spoon = models.TextField()
race = models.FloatField()
big_field = models.TextField()

big_field is only needed in a small number of functions, however the model is used all over the place. How can I avoid big_field being stored in memory? Is this what lazy evaluation is doing? Say I iterated over a QuerySet extracting egg each time, would this cause big_field to be stored in memory also?

Thanks

1
  • Are you sure that big_field is a problem? Have you benchmarked memory usage? Can you provide the details on how you were able to prove that this is causing problems? Can you be specific on what problems this is causing? Slowness? Crashes? Commented Oct 6, 2011 at 10:19

1 Answer 1

3

You can force your queries to fetch only the fields that you want, to save memory.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.