node.js サーバー経由で 2000 x 2000 の 2d 配列を mongoDB インスタンスに挿入しようとしています。
今私がやっている方法は次のとおりです。
for (i=0; i<2000; i++){
//i = height of the tile map
for(x=0; x<2000; x++){
//x is the width of the tile map
driver.mongo.insert('worldTiles', {loc: [x,i], elevation: obj.server.theArray[i][x]}, function (err,results){
if(!err){
}else{
console.log('Ran into an error inserting into worldTiles on Mongo');
}
})
}
console.log(i);
}
現在、私が直面している問題は、576 行目あたりで node.js インスタンスが劇的に遅くなり (40 秒ごとに 1 行処理される)、メモリ不足になることです。これがどのように/なぜ起こっているのかわかりません。
この問題に正しく取り組んでいますか? どうすればこの 2 次元配列を私のデータベースに取り込めるかについてのアイデアはありますか?
助けてくれてありがとう。