Using PyCharm debugger with toolbar results in signficantly slower responses
Hi, Thanks for this library 👍
I have tested and django-debug-toolbar is causing an endless loading GET request in the browser, because the development server just hang processing the request, after check It in detail, I realized that 'debug_toolbar.middleware.DebugToolbarMiddleware' was causing the hang. This happens in the SQL panel aka 'debug_toolbar.panels.sql.SQLPanel', and It happens with a special SQL query:
SELECT * WHERE “TABLE_NAME".”id" IN (ID_1, ID_2, ID_3, .........) LIMIT 21
The slowness seems related to sqlparse. but I couldn't do more checks, so I haven't facts about that.
I was just doing a few performance testing with around 50 000 records.
Removing django-debug-toolbar fixes the issue.
Issue tested in versions: 2.1, 2.2 Current version used: 2.2
Django Settings:
DEBUG = True
INSTALLED_APPS.extend(
('debug_toolbar',
'template_profiler_panel')
)
DEBUG_TOOLBAR_PANELS = {
'debug_toolbar.panels.versions.VersionsPanel',
'debug_toolbar.panels.timer.TimerPanel',
'debug_toolbar.panels.settings.SettingsPanel',
'debug_toolbar.panels.headers.HeadersPanel',
'debug_toolbar.panels.request.RequestPanel',
'debug_toolbar.panels.sql.SQLPanel',
'debug_toolbar.panels.templates.TemplatesPanel',
'debug_toolbar.panels.staticfiles.StaticFilesPanel',
'debug_toolbar.panels.cache.CachePanel',
'debug_toolbar.panels.signals.SignalsPanel',
'debug_toolbar.panels.logging.LoggingPanel',
'debug_toolbar.panels.redirects.RedirectsPanel',
'debug_toolbar.panels.profiling.ProfilingPanel',
'template_profiler_panel.panels.template.TemplateProfilerPanel',
}
Database Used: PostgreSQL 12
Also, I'm using Pycharm 2020.2 Debugger, #1302
Does this slowness occur if you use the CLI python manage.py runserver to run the site? If not, then I'd prefer to close this in favor of #1302.
Also, if you could create a sample project that would reproduce this for you in your environment, that would help expedite the process for fixing this greatly.
I will create it in a sample project with my environment and I will test with only CLI, please keep this opened while I send the details (This week). Thanks for your fast answer!.
I was able to reproduce slowness when using pycharm and the toolbar's example app, but I can't tell what specifically about the toolbar is conflicting with pycharm. For now, I'd suggest avoiding using the toolbar and when using pycharm's debugger.
Renamed the title of this issue to be more explicit about what the concern is.
I reached out to Jetbrains and they recommended I create an issue for PyCharm for them to investigate on their end. The issue for that is here: https://youtrack.jetbrains.com/issue/PY-44534
This also happens with vscode django debugger
@ranjan-purbey can you open a ticket with VSCode to have them look at this issue from their perspective?