Django query slow on profiler but fast on PostgreSQL

507 views Asked by At

Django-live-profiler is showing me a query executed a huge number of time with a slow average time. So the total execution time of the request is high.

Profiler

When I execute the same request directly on PostgreSQL, the query is very fast to execute (less than a millisecond).

EXPLAIN ANALYZE SELECT "auth_user"."id", "auth_user"."password", "auth_user"."last_login", "auth_user"."is_superuser", "auth_user"."username", "auth_user"."first_name", "auth_user"."last_name", "auth_user"."email", "auth_user"."is_staff", "auth_user"."is_active", "auth_user"."date_joined" FROM "auth_user" WHERE "auth_user"."id" = 2;
                                                         QUERY PLAN                                                         
----------------------------------------------------------------------------------------------------------------------------
 Index Scan using auth_user_pkey on auth_user  (cost=0.00..8.27 rows=1 width=133) (actual time=0.051..0.053 rows=1 loops=1)
   Index Cond: (id = 2)
 Total runtime: 0.087 ms
(3 rows)

I am not sure where to dig to find the issue. Most of the requests come through the Django-Rest-framework but I am not sure that it is related.

0

There are 0 answers