Opened 67 minutes ago
#37451 new Uncategorized
`QuerySet.get()` must not pull more than 2 rows with `DEBUG=False`
| Reported by: | Sobolev Nikita | Owned by: | |
|---|---|---|---|
| Component: | Database layer (models, ORM) | Version: | 6.1 |
| Severity: | Low | Keywords: | queryset, orm, database |
| Cc: | Sobolev Nikita | Triage Stage: | Unreviewed |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | yes | UI/UX: | no |
Description
Refs https://code.djangoproject.com/ticket/6785
Source:
- https://github.com/django/django/blob/8e4e95da9b5b751923cd80989d9ece4b6c6fb1a3/django/db/models/query.py#L58-L59
- https://github.com/django/django/blob/8e4e95da9b5b751923cd80989d9ece4b6c6fb1a3/django/db/models/query.py#L741-L746
While this is helpful for debug inforation, it can potentially slow down production requests. With fetching 19 more entries.
This can be especially slow in cases when full-scan is used.
I propose limitting this value to 2 with DEBUG=False. This keeps the best of two worlds:
- Better debug inforation in
DEBUGmode - Faster code in production
Note:
See TracTickets
for help on using tickets.