#12374: QuerySet .iterator() loads everything into memory anyway
-------------------------------------------------------+--------------------
Reporter: Nick Welch <[email protected]> | Owner: nobody
Status: closed | Milestone:
Component: Database layer (models, ORM) | Version: 1.1
Resolution: worksforme | Keywords: orm,
cache, iterator
Stage: Unreviewed | Has_patch: 0
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 0 |
-------------------------------------------------------+--------------------
Comment (by zombie_ninja):
I have experienced the similar problem and I have set DEBUG=False in
settings. I have over 7 million rows of records in my Postgresql database.
My current setup is Debian lenny running django 1.2 (lenny backports),
postgresql 8.3.7
Currently I have been using pagination approach to iterate through all
records as iterator() uses up close to all of my system memory.
However, it was interesting to see that I could iterator through the
dataset by doing the following (using only fraction of my system memory):
query_set = Article.objects.all()
cache = query_set._fill_cache
i = 0
while (True):
try:
r = cache.im_self[i]
print r.id, r.title, r.author
i += 1
except Exception, e:
break
Would appreciate it if someone could give some insight to this.
Regards.
--
Ticket URL: <http://code.djangoproject.com/ticket/12374#comment:5>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.