On 10/12/18 10:51 AM, charettes wrote:
Hello Tobias,

 From my understanding the introduction of chunk_size doest't help here.

The fundamental reason why iterator() cannot be used with prefetch_related() is that the latter requires a set of model instance to be materialized to work appropriately which chunk_size doesn't control at all.

In other words chunk_size only controls how many rows should be fetched from the database cursor and kept into memory at a time. Even when this parameter is used, iterator() will only materialize a single model instance per yield.

I inferred from the original post they were suggesting to do a set of prefetch_related "filling" queries _per_ _chunk_

It wouldn't be as efficient as the 1+P (where P is number of prefetched relations) of a normal prefetch_related, but at 1+(P x Chunks) it would _probably_ be more efficient than the 1+(P x N-rows) it would otherwise be [or worse!]


You received this message because you are subscribed to the Google Groups "Django 
developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
For more options, visit https://groups.google.com/d/optout.

Reply via email to