gpt4 book ai didi

django-models - Django 会自动为外键列生成索引吗?

转载 作者:行者123 更新时间:2023-12-03 05:44:28 25 4
gpt4 key购买 nike

Django 是否自动为外键生成索引,还是仅取决于底层数据库策略?

最佳答案

Django 自动为所有 models.ForeignKey 列创建索引。

来自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.

关于django-models - Django 会自动为外键列生成索引吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5984842/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com