Skip to content
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

Add SQL_TOKEN_GROUPING setting to control token grouping in SQL panel #1404

Closed
wants to merge 8 commits into from
Closed

Conversation

alkihis
Copy link
Contributor

@alkihis alkihis commented Nov 20, 2020

As discussed in #1402, this PR expose a new setting, "SQL_TOKEN_GROUPING" which controls token grouping in SQL panel.
It is set as True by default in order to preserve current behaviour.

It should be disabled if a django application makes a very long textual SQL query, which will cause a huge slowdown during toolbar render.

Copy link
Contributor

@tim-schilling tim-schilling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR should include a test for the functional (not performance) differences when this setting is disabled.

@@ -41,6 +41,7 @@
"SHOW_TEMPLATE_CONTEXT": True,
"SKIP_TEMPLATE_PREFIXES": ("django/forms/widgets/", "admin/widgets/"),
"SQL_WARNING_THRESHOLD": 500, # milliseconds
"SQL_TOKEN_GROUPING": True,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To keep in line with the rest of the settings, this should likely be either ENABLE_SQL_TOKEN_GROUPING or SQL_ENABLE_TOKEN_GROUPING. @matthiask opinions?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pull request which introduced the code in question was this one: #1116

I don't think anyone understands what "token grouping" should be in this context. Maybe something like PRETTIFY_SQL would describe the intent better and allow us to disable or enable additional prettification features with one setting. The NOUN_VERB format seems to be used with many settings, e.g. "show template context", "enable stacktraces" etc.


Controls SQL token grouping.
When set to ``True``, it might cause render slowdowns
when a view make long SQL textual queries.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part of the documentation should briefly explain what grouping of SQL tokens means so that the developer understands what this setting does when it's set to True besides the possible performance impact.

@tim-schilling
Copy link
Contributor

@alkihis This is a great start, thank you for your work so far!

* fix AttributeError: 'dict' object has no attribute 'getlist' #1406

* Revert "fix AttributeError: 'dict' object has no attribute 'getlist' #1406"

* Remove support for Python 3.5

* Remove py35 from tox.ini too; make black target Python 3.6

* Migrate to GitHub Actions. (#1410)

* add test case for generate_stats

* add get_sorted_request_variable and support dict in request data

* fix import

* style check

* style check

* fix style check

* fix request.POST

* History panel: Do not crash when receiving invalid JSON

Fixes #1403

* Add Python3.9 support.

* Add Python and Django supported versions badges to README.rst

* Add two template blocks to allow overriding CSS and JS

* Use alternating quotes (fix highlighting in IDEs)

* django-debug-toolbar 3.2

Co-authored-by: folt <[email protected]>
Co-authored-by: Matthias Kestenholz <[email protected]>
Co-authored-by: Jannis Leidel <[email protected]>
Co-authored-by: Hasan Ramezani <[email protected]>
Co-authored-by: Peter Bittner <[email protected]>
@codecov
Copy link

codecov bot commented Dec 4, 2020

Codecov Report

Merging #1404 (137d705) into master (b66d1c0) will decrease coverage by 0.29%.
The diff coverage is 87.50%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1404      +/-   ##
==========================================
- Coverage   88.00%   87.71%   -0.30%     
==========================================
  Files          29       29              
  Lines        1576     1579       +3     
  Branches      221      221              
==========================================
- Hits         1387     1385       -2     
- Misses        140      142       +2     
- Partials       49       52       +3     
Impacted Files Coverage Δ
debug_toolbar/panels/cache.py 83.58% <ø> (ø)
debug_toolbar/panels/sql/utils.py 90.19% <66.66%> (-1.65%) ⬇️
debug_toolbar/panels/history/panel.py 95.83% <100.00%> (+0.08%) ⬆️
debug_toolbar/panels/request.py 100.00% <100.00%> (ø)
debug_toolbar/panels/settings.py 87.50% <0.00%> (-12.50%) ⬇️
debug_toolbar/panels/sql/tracking.py 87.71% <0.00%> (-1.76%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b66d1c0...137d705. Read the comment docs.

@matthiask
Copy link
Member

Hmm, something went wrong while updating this pull request it seems. Since 300d61e the pull request diff contains unrelated changes applied to the master branch in the meantime.

I'd be grateful if you would clean up this pull request and only include your changes, not everything else. (Don't hesitate to ask for help if you need some support with git for this.)

@alkihis
Copy link
Contributor Author

alkihis commented Jan 21, 2021

Replaced by #1438

@alkihis alkihis closed this Jan 21, 2021
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