[Django] #36593: Deprecate select_related() with no arguments

3 views
Skip to first unread message

Django

unread,
Sep 4, 2025, 6:29:00 AM (3 days ago) Sep 4
to django-...@googlegroups.com
#36593: Deprecate select_related() with no arguments
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Type:
| Cleanup/optimization
Status: new | Component: Database
| layer (models, ORM)
Version: dev | Severity: Normal
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Currently, it’s possible to call `select_related()` with no arguments,
[https://docs.djangoproject.com/en/5.2/ref/models/querysets/#django.db.models.query.QuerySet.select_related
documented thusly]:

> There may be some situations where you wish to call `select_related()`
with a lot of related objects, or where you don’t know all of the
relations. In these cases it is possible to call `select_related()` with
no arguments. This will follow all non-null foreign keys it can find -
nullable foreign keys must be specified. This is not recommended in most
cases as it is likely to make the underlying query more complex, and
return more data, than is actually needed.


In [https://github.com/django/django/pull/17554#discussion_r2072398386 a
comment thread] discussing `select_related()` with no arguments, four
contributors agreed it would be worth deprecating, due to its poor
performance implications, degrading every time the given model gains a
relation.

This deprecation would need to affect both `select_related()` with no
arguments and the `ModelAdmin.list_select_related = True` option that uses
it.
--
Ticket URL: <https://code.djangoproject.com/ticket/36593>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Sep 4, 2025, 7:29:26 AM (3 days ago) Sep 4
to django-...@googlegroups.com
#36593: Deprecate select_related() with no arguments
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: (none)
Type: | Status: new
Cleanup/optimization |
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Clifford Gama):

* stage: Unreviewed => Accepted

--
Ticket URL: <https://code.djangoproject.com/ticket/36593#comment:1>

Django

unread,
Sep 5, 2025, 10:07:31 AM (2 days ago) Sep 5
to django-...@googlegroups.com
#36593: Deprecate select_related() with no arguments
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: Adam
Type: | Johnson
Cleanup/optimization | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Adam Johnson):

* owner: (none) => Adam Johnson
* status: new => assigned

--
Ticket URL: <https://code.djangoproject.com/ticket/36593#comment:2>

Django

unread,
Sep 5, 2025, 10:12:45 AM (2 days ago) Sep 5
to django-...@googlegroups.com
#36593: Deprecate select_related() with no arguments
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: Adam
Type: | Johnson
Cleanup/optimization | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Adam Johnson):

* has_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/36593#comment:3>
Reply all
Reply to author
Forward
0 new messages