-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Conversation
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.
This PR should include a test for the functional (not performance) differences when this setting is disabled.
debug_toolbar/settings.py
Outdated
@@ -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, |
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.
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?
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.
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. |
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.
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.
@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 <foltfrend@list.ru> Co-authored-by: Matthias Kestenholz <mk@feinheit.ch> Co-authored-by: Jannis Leidel <jannis@leidel.info> Co-authored-by: Hasan Ramezani <hasan.r67@gmail.com> Co-authored-by: Peter Bittner <django@bittner.it>
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
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.) |
Replaced by #1438 |
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.