Open ritiksoni00 opened 1 year ago
Thanks for trying this out! Sorry for a bit of a delay in responding.
REQUEST_LOGGING_DETAILED_DB_QUERY_DIAGNOSTICS_THRESHOLD
limits the detailed output (query and call stacks) to only those queries that repeat more than the number specified in the threshold. I will add a more detailed explanation near the setting.
removing all the function calls and getting only files name would be good?
Because the output is ordered by the most repeated calls being first, you can start to chip away at them from top to bottom -- from the places in the code that account for the most calls first. I am guessing these are not 50 unique queries, but that there are some that are repeating and you can achieve quick reductions by focusing on the top of the list. Yes, it is messy, but the call stacks tell you exactly where the queries are coming from. Just having the file names may not be enough to pinpoint the offending code. And of course the idea is that you only enable this output while troubleshooting. Once you reduce the queries to something more reasonable, this logging can be disabled. And in production, you definitely only want to the high level stats per request and not the detailed logs.
Also, for more user-friendly and interactive troubleshooting, you can try to integrated https://github.com/jazzband/django-debug-toolbar, but that can involve a bit more work depending on your setup.
Hope this helps!
Note, I updated the readme to say
REQUEST_LOGGING_DETAILED_DB_QUERY_DIAGNOSTICS_THRESHOLD controls at what number of repeats the query diagnostrics will be output, default being 0. So for example if you want to only see detailed logs about queries that repeat 5 times or more, set this value to 5.
Thanks, Now I'm clear all about this.
So I'm gonna use this in Production. also #3 can be merged for ASGI support..
REQUEST_LOGGING_DETAILED_DB_QUERY_DIAGNOSTICS_THRESHOLD controls above what number of repeats a query will be logged, default is 0
I didn't get this line. what it actually means.
and thanks for making it OS.
another question:- when we enable detailed query and if that request is doing around 50 DB calls (worst case) then getting information from
stack_str
stack_str = "".join(traceback.format_stack())
doesn't help much it will be a mess.removing all the function calls and getting only files name would be good? I'm not sure. what will you suggest?