In django i am trying to understand prefetch:
I have two for loop scenarios after prefetch
symbollist = SymbolList.objects.prefetch_related('some_related_name')[0:10]
for i in range(0,10):
print(symbollist[i].some_related_name)
Now it calls sql N+1 times
where as
symbollist = SymbolList.objects.prefetch_related('some_related_name')[0:10]
for symbol in symbollist:
print(symbol.some_related_name)
this will call only two sqls
Why so