这种django应用程序模型结构之间是否存在显著的性能差异?
第一种情况,这种django应用程序模型结构之间是否存在显著的性能差异?,django,Django,第一种情况, app_1 - post_model_1 app_2 - post_model_2 (has Foreign Key Field to post_model_1) app_3 - post_model_3 (has Foreign Key Field to post_model_1) app_1 - post_model_1, post_model_2 (has Foreign Key Field to post_model_1), pos
app_1 - post_model_1
app_2 - post_model_2 (has Foreign Key Field to post_model_1)
app_3 - post_model_3 (has Foreign Key Field to post_model_1)
app_1 - post_model_1,
post_model_2 (has Foreign Key Field to post_model_1),
post_model_3 (has Foreign Key Field to post_model_1),
第二种情况,
app_1 - post_model_1
app_2 - post_model_2 (has Foreign Key Field to post_model_1)
app_3 - post_model_3 (has Foreign Key Field to post_model_1)
app_1 - post_model_1,
post_model_2 (has Foreign Key Field to post_model_1),
post_model_3 (has Foreign Key Field to post_model_1),
如果我不喜欢使用ForeignKeyField将所有相关帖子(无论是post_model_2还是post_model_3)发布到post_model_1
第一种情况和第二种情况之间是否存在性能差异?
如果是,哪个更快?两者之间没有区别。它们是一样的。在第一种情况下创建的表(模型)与在第二种情况下创建的表(模型)相同 请注意,Django应用程序不确定数据库模型(表),但
Model
s确定。因此,在这两种情况下,您都有精确的模型结构(三个带有ForeignKey
relatioships的表)。因此,无论是“更快”还是“更好”
在第一种情况下,您将执行以下操作:
from app_1 import post_model_1
from app_2 import post_model_2
from app_3 import post_model_3
from app_1 import post_model_1, post_model_2, post_model_3
在第二种情况下,您可以:
from app_1 import post_model_1
from app_2 import post_model_2
from app_3 import post_model_3
from app_1 import post_model_1, post_model_2, post_model_3
查询集仍将保持不变。谢谢!!这是有帮助的。