[Django] #36046: Create an index on the combination of ForeignKeys in the ManyToManyField through table?

12 views
Skip to first unread message

Django

unread,
Dec 31, 2024, 5:54:52 AM12/31/24
to django-...@googlegroups.com
#36046: Create an index on the combination of ForeignKeys in the ManyToManyField
through table?
-------------------------------------+-------------------------------------
Reporter: Willem Van Onsem | Type:
| Uncategorized
Status: new | Component: Database
| layer (models, ORM)
Version: 5.1 | 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
-------------------------------------+-------------------------------------
As [https://stackoverflow.com/q/79318183/67579 this SO question] points
out, Django apparently does not create an index on the *combination* of
the two `ForeignKey`s. It might be an idea to automatically do this?
--
Ticket URL: <https://code.djangoproject.com/ticket/36046>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Dec 31, 2024, 8:21:08 AM12/31/24
to django-...@googlegroups.com
#36046: Create an index on the combination of ForeignKeys in the ManyToManyField
through table?
-------------------------------------+-------------------------------------
Reporter: Willem Van Onsem | Owner: (none)
Type: | Status: closed
Cleanup/optimization |
Component: Database layer | Version: 5.1
(models, ORM) |
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* resolution: => wontfix
* status: new => closed
* type: Uncategorized => Cleanup/optimization

Comment:

Django automatically adds a unique constraint for these two fields which
is effectively an index, there is no need to add another one.
--
Ticket URL: <https://code.djangoproject.com/ticket/36046#comment:1>

Django

unread,
Dec 31, 2024, 8:21:52 AM12/31/24
to django-...@googlegroups.com
#36046: Create an index on the combination of ForeignKeys in the ManyToManyField
through table?
-------------------------------------+-------------------------------------
Reporter: Willem Van Onsem | Owner: (none)
Type: | Status: closed
Cleanup/optimization |
Component: Database layer | Version: 5.1
(models, ORM) |
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* cc: Mariusz Felisiak (added)

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