1

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.

Chris Travers
  • 25,424
  • 6
  • 65
  • 182
poiuytrez
  • 21,330
  • 35
  • 113
  • 172
  • Are you using transactions? – Maciej Gol Dec 06 '13 at 12:56
  • @kroolik I do not think that the query is run inside a transaction. – poiuytrez Dec 06 '13 at 13:03
  • 2
    Any chance (1) of a clue as to what those numbers-without-headings mean in that screenshot, and (2) pasting the actual text rather than an image? – Richard Huxton Dec 06 '13 at 15:12
  • Are you executing the exact same query after seeing it in the profiler within Postgres? If so its likely cached. Try changing the user_id within Postgres and see if that changes it. Though overall grabbing such a simple result should be fast, so possibly you're running it multiple times. – CraigKerstiens Dec 08 '13 at 18:05

0 Answers0