Hi,
Could someone please let me know what the implications of Django queryset iterator on select_related and prefetch_related?
Also, I am still not quite clear on the concept of iterator which I understand returns a Generator. Whenever a for loop is run on the Generator, the DB is queried for each element in the for loop - if my understanding is correct. The result of the Query is not stored in the memory. So, for some model A,
qs = A.objects.all() which probably does 'Select "all columns/fields'" from A in some order". This would probably fetch the results in one go. I am not sure how the iterator() changes this.
BTW I observed that the iterator doesn't work like a typical Generator. Repeated call with next() on the Generator produces the same value.
Would appreciate if someone could explain the above or provide any reference.
Thanks.