开发者

Does Django automatically generate indexes for foreign keys columns?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜