call or replay me I am interested +918709440658

On Sun, 19 Jul 2020, 9:11 am karthik challa, <[email protected]>
wrote:

> Hi Experts,
>
> I am trying to execute a Django query (ORM) but my query is taking more
> than  4 mins as the table have huge records.
>
> Here are the details
>
> 1> I am using left outer join to get count from other table
>
> 2>Django query
> subject = Table1.objects.all().annotate(numItems=Count('table2.field')).
> order_by('name')
>
>
>
> 3>Here I am converting the above query set to Raw sql
> SELECT "table1"."id", "table1"."created_at", "table1"."name", COUNT(
> "table2"."id") AS "numItems" <http://localhost:8000/urls/search/#> FROM
> "table1" LEFT OUTER JOIN "table2" ON ("table1"."id" = "table2".
> "subdomain_id") GROUP BY "table1"."id" ORDER BY "table1"."name" ASC
>
> and I am returning response to template index.html
>
> response = render(request, 'search_home.html', context)
>
>
> My template looks like this
> {% if context.subject %}
> {% for item in context.subject %}
> {{ item }}
> {% endfor %}
> {% endif %}
> Please  let me know how can i reduce the performance time or how can i
> optimize the query .
>
> Thanks & Regards,
> Karthik
>
> --
> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-developers/ab90edb2-7d5e-4e01-9fad-0c71cb916a67o%40googlegroups.com
> <https://groups.google.com/d/msgid/django-developers/ab90edb2-7d5e-4e01-9fad-0c71cb916a67o%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/CAJP%3DbzCehTLi3znPp%2Bv1zKPJ20VbhbNJS2nEHox%2BPKjMTrhLkA%40mail.gmail.com.

Reply via email to