I'm using Django for a large app. When monitoring the DB (Postgres) I sometimes see a few slow queries log written.
The problem is how to track down the code that generated these queries. optimally I want some stack trace for these logs, but wonder if there is some other best-practice, or maybe some other tool.
It's in production so DEBUG is set to False, so Django itself doesn't track the speed of the queries.
P.S - I saw somewhere someone suggesting to add SQL comment to the SQL query itself. Unfortuantely this doesn't seem to be generally available in Django, and also it will require me to update every single code that generates queries.