Does django automatically create indexes for foreign key columns?

Is Django automatically generating indexes for foreign keys or is it dependent only on the underlying database policy?

+46
django-models
May 12 '11 at 21:44
source share
1 answer

Django automatically creates an index for all models.ForeignKey columns.

From the Django Documentation :

The database index is automatically created on ForeignKey . You can disable this by setting db_index to False . You can avoid the overhead of an index by creating a foreign key for consistency rather than joining, or if you create an alternative index, such as partial or multiple columns.

+64
May 15 '11 at 19:02
source share



All Articles