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.
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
Old description:
> 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"],
> ]
New description:
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:
<code>
class Meta:
index_together = [
["content_type", "object_id"],
]
</code>
--
--
Ticket URL: <https://code.djangoproject.com/ticket/26964#comment:1>
Old description:
> 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:
>
> <code>
> class Meta:
> index_together = [
> ["content_type", "object_id"],
> ]
> </code>
New description:
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#comment:2>
Old description:
> 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"],
> ]
> ```
New description:
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#comment:3>
* status: new => closed
* resolution: => duplicate
Comment:
I'll mark this as a duplicate of #23435 which suggests we might change the
behavior and automatically add the index you describe. Feel free to give
that implementation a try or to submit a documentation PR referencing that
ticket (commit message = "Refs #23435 -- ....").
--
Ticket URL: <https://code.djangoproject.com/ticket/26964#comment:4>
Comment (by Daniel Hahler):
@Aidan:
> Once we'd resolved that, we noticed a contrib app had no index either
(django reversion).
I've created https://github.com/etianen/django-reversion/issues/754 to
track this - would be good if you could provide more info there, e.g. when
this is needed/useful.
--
Ticket URL: <https://code.djangoproject.com/ticket/26964#comment:5>