-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Description
Description
When SQL queries contain large IN clauses with thousands of parameters (e.g., UUIDs), the SQL panel either:
- Freezes for 10-18+ seconds (sqlparse < 0.5.5)
- Crashes with SQLParseError (sqlparse >= 0.5.5)
This is a common pattern when fetching IDs from one query and filtering by them in another:
job_ids = list(Campaign.objects.filter(...).values_list('job_id', flat=True))
# job_ids contains 5000+ UUIDs
applications = JobApplication.objects.filter(job_id__in=job_ids)Behavior Matrix
| debug-toolbar | sqlparse | When | Behavior |
|---|---|---|---|
| <= 5.x | < 0.5.5 | Page load | Freezes 10-18+ seconds |
| <= 5.x | >= 0.5.5 | Page load | SQLParseError crash |
| >= 6.x | < 0.5.5 | SQL panel click | Freezes 10-18+ seconds |
| >= 6.x | >= 0.5.5 | SQL panel click | SQLParseError crash |
Demo
debug-toolbar 5.2 + sqlparse 0.5.3 (page freezes)
debug-toolbar 6.1 + sqlparse 0.5.5 (SQLParseError)
Reproduction
A minimal reproduction project is available:
👉 https://github.com/kkm-horikawa/debug-toolbar-perf-issue
git clone https://github.com/kkm-horikawa/debug-toolbar-perf-issue.git
cd debug-toolbar-perf-issue
uv sync
uv run python manage.py migrate
uv run python manage.py runserver
# Visit http://127.0.0.1:8000/slow/?count=5000Current Workaround
DEBUG_TOOLBAR_CONFIG = {
'PRETTIFY_SQL': False, # Disables ALL SQL formatting
}This disables formatting for all queries, not just problematic ones.
Related
Metadata
Metadata
Assignees
Labels
No labels