I've used this post to profile a ajax django view with a json response. The following are by far the largest time suckers:
ncalls tottime percall cumtime percall filename:lineno(function)
1 1.502 1.502 1.502 1.502 c:\python27\lib\socket.py:336(read)
1 1.501 1.501 1.501 1.501 c:\users\jonathan\virtual_environments\myapp\lib\site-packages\psycopg2\__init__.py:119(connect)
2 0.749 0.375 0.749 0.375 c:\users\jonathan\virtual_environments\myapp\lib\site-packages\django\db\backends\postgresql_psycopg2\base.py:50(execute)
1 0.245 0.245 0.245 0.245 c:\python27\lib\socket.py:406(readline)
2 0.240 0.120 1.741 0.871 c:\users\jonathan\virtual_environments\myapp\lib\site-packages\django\db\backends\postgresql_psycopg2\base.py:157(_cursor)
Hey, what's that?!? postgresql database access? But the view code doesn't even access the database!
@login_required
@debug_ajax
@json_error_on_exception
def my_ajax_view(request):
json_response = redis_conn.get('precompiled-json-response')
return HttpResponse(json_response, mimetype='application/json')
I checked the decorators and only the django auth native @login_required
is suspect.
How can I debug this? How can I see the queries issued?
Even if auth does query the db, these response times are insane. How can I further drill down to see what's up?
Install Django Debug Toolbar. And See the response times and sql query times.