2017-03-17 1 views
1

まず場合、この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), 
     post_model_3 (has Foreign Key Field to post_model_1), 

私はForeignKeyField、

を使用してpost_model_1する(それはpost_model_2、またはpost_model_3あるものは何でも)すべての関連記事を得るようなクエリセットない場合

ファーストケースとセカンドケースの違いはありますか?

これは高速ですか?

答えて

3

2つの間に違いはありません。彼らは同じです。最初のケースで作成した同じテーブル(モデル)、2番目のケースで作成したものと同じもの。

Djangoアプリケーションはデータベースモデル(テーブル)を特定しませんが、Modelはそうです。したがって、どちらの場合もモデルの正確な構造(ForeignKey relatioshipsの3つのテーブル)があります。だから、その "速い"か "良い"のどちらもありません。あなたがどうなる最初のケースで

from app_1 import post_model_1 
from app_2 import post_model_2 
from app_3 import post_model_3 

ながら、あなたはどうなる秒1で:

from app_1 import post_model_1, post_model_2, post_model_3 

クエリセットは同じままになります。

+0

ありがとうございます!それは助けられる。 – touchingtwist

関連する問題