On 8/27/07, Jeremy Dunck <[EMAIL PROTECTED]> wrote:
> QuerySet.iterator does what you want.

I was going to follow up with a documentation link, but it appears we
lost the documentation for QuerySet.iterator at some point. Opened a
ticket

In any case, Jeremy's right: the "iterator" method returns a generator
which fetches the data in chunks and only instantiates objects when
they're actually needed, yielding them one at a time as you iterate
over it. So you can replace a call to 'all()' with a call to
'iterator()', or chain 'iterator()' on after a call to 'filter()', and
you should see greatly improved memory usage for situations where
you're dealing with huge numbers of objects.


-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to