Skip to content

Conversation

@ewjoachim
Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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...)

@tim-schilling
Copy link
Member

As an example here here's what the output will now look like:
image

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?

@ewjoachim
Copy link
Contributor Author

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 <tr> ?)

@aaugustin
Copy link
Contributor

@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.

@tim-schilling
Copy link
Member

Okay cool. I'm going to merge this in then and we can iterate on it.

tim-schilling added a commit that referenced this pull request Jun 7, 2015
Display the count of SQL duplicates (fixes #27)
@tim-schilling tim-schilling merged commit 872df6b into django-commons:master Jun 7, 2015
@aaugustin
Copy link
Contributor

Thanks Tim!

@ewjoachim
Copy link
Contributor Author

Thank you @tim-schilling , and @aaugustin , I'll try to continue in this direction :)

ryneeverett pushed a commit to ryneeverett/django-debug-toolbar that referenced this pull request Oct 2, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants