On Tue, Feb 17, 2009 at 1:50 PM, Ian Kelly <[email protected]> wrote:
> > On Tue, Feb 17, 2009 at 7:40 AM, M N Islam Shihan <[email protected]> > wrote: > > > > Hi, > > > > Please go through the comments of the blog post you are referring and > you'll > > understand why, how and where to use the django ORM. > > > > Regards, > > Shihan > > Something I've just noticed here. One of the comments links to the > documentation for QuerySet.iterator: > http://docs.djangoproject.com/en/dev/ref/models/querysets/#iterator > > The documentation includes the statement, "A QuerySet typically reads > all of its results and instantiates all of the corresponding objects > the first time you access it; iterator() will instead read results and > instantiate objects in discrete chunks, yielding them one at a time." > > Am I mistaken, or is this not exactly correct? As I understand it, > the difference between QuerySet.__iter__ and QuerySet.iterator isn't > that the former reads and instantiates everything all at once, but > that the former will make use of the QuerySet's result cache, reading > from it when available and filling it as a side effect of iteration. > > Ian > > > > Neither is completely correct ;). Both do chunked reads from the DB(__iter__ using iterator for getting the data), however __iter__ also caches them, so if you reiterate you don't do a second db query, whereas iterator doesn't cache them. Alex -- "I disapprove of what you say, but I will defend to the death your right to say it." --Voltaire "The people's good is the highest law."--Cicero --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django developers" 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-developers?hl=en -~----------~----~----~----~------~----~------~--~---
