Commit 69d3feb7 authored by fred's avatar fred
Browse files

performance: prefetch categories in listen page (190 -> 12 SQL queries)

parent 8c292fda
...@@ -482,7 +482,7 @@ class Listen(TemplateView): ...@@ -482,7 +482,7 @@ class Listen(TemplateView):
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super(Listen, self).get_context_data(**kwargs) context = super(Listen, self).get_context_data(**kwargs)
context['sectionName'] = "Listen" context['sectionName'] = "Listen"
context['episodes'] = Episode.objects.filter( context['episodes'] = Episode.objects.prefetch_related('emission__categories').filter(
soundfile__podcastable=True, soundfile__fragment=False) \ soundfile__podcastable=True, soundfile__fragment=False) \
.select_related().extra(select={ .select_related().extra(select={
'first_diffusion': 'emissions_diffusion.datetime', }, 'first_diffusion': 'emissions_diffusion.datetime', },
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment