各行が ID、グループ ID、および追加データで構成されている非常に長いテキスト ファイルを読み込んでいます。各 ID は多くの groupID に関連付けることができ (行 1、2、3)、各 ID-groupID の組み合わせは多くのデータに関連付けることができます (行 2、3)。
JWOFJ903JCKDF8O | groupID-22 | some data
JWOFJ903JCKDF8O | groupID-33 | same ID as above, but different groupID and data
JWOFJ903JCKDF8O | groupID-33 | same ID and groupID as above, but different data
...
DF8#CKJ90JJ3WOF | groupID-22 | some data
...
このデータをデータベースに移動しているので、ID のテーブル (ID の重複なし)、ID と groupID のテーブル (ID-groupID の重複なし)、ID を参照するデータのテーブルがあります。 -groupID テーブル。
データベースに 1 行挿入するには、まずこの ID が ID テーブルに存在しないことを確認してから挿入します。次に、この ID-groupID の組み合わせが ID-groupID テーブルに存在しないことを確認してから、挿入します。最後に、この ID-groupID id の下にデータを挿入します。
does this $id exist in the IDs table
if($id doesn't exist in the IDs table){
insert a new ID()
save()
}
does this ID-groupID combo exist in the ID-groupID table
if(doesn't exist){
create new id-groupid combo
}
does this data exist under the third table in association with this id-groupid combo
if(doesn't exist){
insert it
}
問題は、ファイルが非常に大きい (100,000 行) ため、プロセスが完了するまでに数時間かかることです。propel クエリを最適化するためにできることはありますか? またはデータベースの設計を改善しますか?