#23435: GFK should be indexed
-------------------------------------+-------------------------------------
Reporter: aaugustin | Owner: nobody
Type: | Status: new
Cleanup/optimization | Version: master
Component: Database | Keywords:
layer (models, ORM) | Has patch: 0
Severity: Normal | Needs tests: 0
Triage Stage: | Easy pickings: 0
Unreviewed |
Needs documentation: 0 |
Patch needs improvement: 0 |
UI/UX: 0 |
-------------------------------------+-------------------------------------
(Yes, I know GFKs are evil and should be avoided at all costs.
Nonetheless, as long as Django supports them, people will use them.)
Django automatically adds an index on foreign keys, for fast reverse
lookups, unless it's explicitly disabled with `db_index = False`.
I believe it should also add an index on `(content_type, object_id)` on
GFK. If we make this the default in a future version of Django, users will
just have to run `makemigrations` on apps that have a GFK and they'll get
the index for free.
The alternative would be to update the documentation to recommend adding
the index explicitly.
{{{
class Meta:
index_together = [('content_type', 'object_id')]
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/23435>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/052.49b1a6f9d564c4e31660b1b98cd61fac%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.