Maybe https://code.djangoproject.com/ticket/25546 fixes it? This will be in 
Django 1.10.

On Friday, February 12, 2016 at 10:18:22 PM UTC-5, Dheerendra Rathor wrote:
>
> Hello,
>
> Recently I was monitoring db queries created by Django and a particular 
> block was behaving unusual.
> Here is the code block:
>
>         from django.db import connection, reset_queries
>         reset_queries()
>         group = get_object_or_404(
>             Group.objects.select_related('course').prefetch_related(
>                 Prefetch(
>                     'concepts',
>                     
> queryset=Concept.objects.filter(is_published=True).prefetch_related(
>                         'videos', 'pages',
>                     ),
>                 ),
>             ).only('course', 'playlist'),
>             pk=pk,
>         )
>
>         s4 = connection.queries
>         k4 = len(s4)
>         reset_queries()
>
>
>
> Now, the interesting part is that prefetch queries are made twice for 
> videos and pages. Hereis the query dump https://paste.kde.org/psrp4orn6
>
> It is making same queries twice with exactly same parameters. 
>
> Can someone please explain it for me? In my view, it should not happen. 
> I'm missing something here? 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a8a7e2f6-999f-4eaa-a045-bcf187c11b94%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to