开发者

Does Django automatically generate indexes for foreign keys columns?

开发者 https://www.devze.com 2023-03-05 18:49 出处:网络
Does Django automatically generate indexes for foreign keys, or does it just depend on the unde开发者_开发知识库rlying DB policy ?Django automatically creates an index for all models.ForeignKey column

Does Django automatically generate indexes for foreign keys, or does it just depend on the unde开发者_开发知识库rlying DB policy ?


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

From Django documentation:

A database index is automatically created on the ForeignKey. You can disable this by setting db_index to False. You may want to avoid the overhead of an index if you are creating a foreign key for consistency rather than joins, or if you will be creating an alternative index like a partial or multiple column index.

0

精彩评论

暂无评论...
验证码 换一张
取 消