2016-12-13 6 views
0

の多くを取っている、私は仕事に数秒かかり集約パイプラインを実行しました:

db.aarhus_ways.aggregate([{$lookup:{from: "aarhus_nodes",localField: 
"node_refs",foreignField: "id",as: "nodes"}},{"$project": 
{"id":1,"name":1,"highway":1,"nodes.pos":1}}]) 

今、私はこれを追加しますデッドタイムが遅くなるコレクションに出力します。

db.aarhus_ways.aggregate([{$lookup:{from: "aarhus_nodes",localField: 
"node_refs",foreignField: "id",as: "nodes"}},{"$project": 
{"id":1,"name":1,"highway":1,"nodes.pos":1}} 
,{"$out":"nodes"}]) 

これで30分経過し、集計はまだ実行されています。 は、それが正常であるデータは、MongoDBの中で(バイト)かかりデンマークのオーフス市に関係することを仮定して:

db.aarhus_ways.totalSize() --> 7991296 = nearly 8 MB 
db.aarhus_nodes.totalSize() --> 35987456 = nearly 36 MB 

答えて

0

まず、あなただけのコマンドを発行することにより、ローカルおよびforeignFieldにインデックスを作成する必要があります。

db.aarhus_ways.createIndex({node_refs:1}) 
db.aarhus_nodes.createIndex({id:1}) 

次のコマンドを実行します。

db.aarhus_ways.aggregate([{ 
    $lookup: { 
     from: "aarhus_nodes", 
     localField: "node_refs", 
     foreignField: "id", 
     as: "nodes" 
    } 
},{ 
    "$project": { 
     "id":1, 
     "name":1, 
     "highway":1, 
     "nodes.pos":1 
    } 
},{ 
    "$out":"nodes" 
}]) 
関連する問題