Reputation: 929
We've got some really strange extraneous DB hits happening in our project. Is there any way to monitor where the requests are coming from, possibly by line number? The SQL printing middleware helps, but we've looked everywhere those kinds of requests might be generated and can't find the source.
If the above isn't possible, any pointers on narrowing down the source would be greatly appreciated.
Upvotes: 2
Views: 2494
Reputation: 3649
if you want track SQL queries for performance optimization and debug purpose and how to monitor query call in Django for that this blog will help you out
Tracking SQL Queries for a Request using Django
Upvotes: 0
Reputation: 3784
To find the code executing queries, you can install django-debug-toolbar to figure out what commands are being executed and which tables they're operating on.
Once you've done that, try hooking into the appropriate Django signals for those models and using print
and assert
to narrow the code.
I'm sure there's a better way to do some of this (a python debugger?) but this is the first thing that comes to mind and probably what I would end up doing myself.
Upvotes: 4