-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Display the count of SQL duplicates (fixes #27) #719
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
debug_toolbar/panels/sql/panel.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Until now we haven't used dict comprehensions because we're supporting Django 1.4 and Python 2.5. 1.4 is still supported until October 1st.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done :) (used dict((a,b) for a, b in ...), that should be better...)
|
As an example here here's what the output will now look like: It appears that a query will be counted as a duplicate depending on the query alone rather than the actual values of the parameters. I think that this will work for most cases and is better than checking the parameter values. One thing that I'm not thrilled about is that there's no distinction between which queries are duplicates of which. It's easy to which query is being duplicated in the example I posted, but I could see this being difficult with more complex pages. To mitigate this, I can see this being a separate tab on the SQL Panel while the main panel would continue to be what exists currently. That way a developer could see what the flow of queries is and then see a barebones list of the duplicated ones. All that said, I'm leaning towards merging this because it does improve the toolbar. What are your thoughts @aaugustin? |
|
Yeah, I thought it wasn't a good idea to radically change the SQL panel, but, indeed, creating a new tab that would display the information without the timeline but with a cleaner way to show how duplicates are grouped could help a lot when trying to find which loop create a cascade of queries. Regarding the "Which queries are duplicates" question, would you like me to try to add a color information (like a thin rectangle filled with a solid color on the left of the |
|
@tim-schilling I discussed this with @ewjoachim before he implemented it at the DjangoCon Europe sprints. His work goes in the right direction. Adding a visual cue that queries are duplicated would be nice. I've thought of "folding" duplicated queries in a single line but that'll make it impossible to display the parameters of each query, which may be a problem. |
|
Okay cool. I'm going to merge this in then and we can iterate on it. |
Display the count of SQL duplicates (fixes #27)
|
Thanks Tim! |
|
Thank you @tim-schilling , and @aaugustin , I'll try to continue in this direction :) |
Display the count of SQL duplicates (fixes django-commons#27)

This if my most successful approach at fixing #27
If we stick to just displaying the number of duplicates for each database connection and each query, we get some information, and it will help debugging.
I've been trying to push it a bit further and trying to display only the unique queries at first, with a simple way of showing everything and clear way to understand the groups but I couldn't get something easily understandable without changing the whole UI (which may be interesting, but is definitely out of the scope of this ticket).
That being said, I have some ideas and I'll try to implement something at some point.