On 8/28/07, Tomas Kopecek <[EMAIL PROTECTED]> wrote: ... > For me it could be more appropriate to change iterator() to do some > slicing for me (by explicit LIMIT clause), maybe a small patch for our > application. I understand, that changing it in general would be a bad > design decision.
Ick. :) Consider subclassing queryset to override __iter__ and do the chunking yourself. This is bad in the sense that it does n+1 queries to chunk it, but you said that it wasn't needed that often. Also, note that if you need a consistent read (despite other processes committing between chunk selects), then you'll need to change your transaction isolation level: http://en.wikipedia.org/wiki/Transaction_isolation_level class MyQuerySet(QuerySet): def __iter__(self): import itertools import math count = self.count() chunk_size = 1000 #or whatever makes sense to you chunks = [] for i in range(0, math.ceil(float(count)/chunk_size)): print i chunks.append(self[chunk_size*i:chunk_size*(i+1)].iterator()) return itertools.chain(*chunks) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---