#26964: No mention of index_together on the GenericForeignKey section
-------------------------------+--------------------
Reporter: aidanlister | Owner: nobody
Type: Bug | Status: new
Component: Documentation | Version: 1.9
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+--------------------
We've been troubleshooting a performance issue and noticed that there was
no index on an important GenericForiegnKey.
Once we'd resolved that, we noticed a contrib app had no index either
(django reversion).
It seems like this should be mentioned in the documentation here:
https://docs.djangoproject.com/en/1.9/ref/contrib/contenttypes/#generic-
relations
Suggested wording:
If you plan to search for child objects which have a generic relation to
your parent object, e.g. find all tags linked to a piece of content, then
you should consider adding a database index on the content type and object
ID using ``index_together``
(https://docs.djangoproject.com/en/1.9/ref/models/options/#index-
together). Django does not do this for you automatically as it does with
ForeignKey's.
In the example above, this would look like:
class Meta:
index_together = [
["content_type", "object_id"],
]
--
Ticket URL: <https://code.djangoproject.com/ticket/26964>
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/054.817669a4e1132afc549c6ad4415b0a95%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.