﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
23435	GenericForeignKey should be indexed	Aymeric Augustin	nobody	"(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')]
}}}
"	Cleanup/optimization	new	contrib.contenttypes	dev	Normal				Accepted	0	0	0	0	0	0
