Opened 3 weeks ago
Closed 3 weeks ago
#37451 closed Cleanup/optimization (wontfix)
`QuerySet.get()` must not pull more than 2 rows with `DEBUG=False`
| Reported by: | Sobolev Nikita | Owned by: | mudassar |
|---|---|---|---|
| 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
Change History (2)
comment:1 by , 3 weeks ago
| Owner: | set to |
|---|---|
| Status: | new → assigned |
comment:2 by , 3 weeks ago
| Resolution: | → wontfix |
|---|---|
| Status: | assigned → closed |
| Type: | Uncategorized → Cleanup/optimization |
Note:
See TracTickets
for help on using tickets.
We would need some consensus on the DevelopersMailingList (now the Django forum) in order to change the original design decision. You're welcome to make a post there.