2016-03-28 13 views
2

telemNameテーブルの名前を変更して新しいデータを取得すると、NodeJSを使用してこのコードは正常に動作します。常に持っています。しかし、私が今持っているコレクションが検索結果の合計を違反した:1649272MongoDB大量のデータを並べ替え

db.collection(telemName).find(options).sort({ "d" : 1 }).toArray(function (err, telemetryData) { 
    console.log(telemetryData.length, "data points to insert"); 
    var newlastInsert = telemetryData[telemetryData.length - 1].d; 
    callback(null, db, telemetryData, newlastInsert) 
}); 

なぜ私のソートはエルゴはこのエラーを得、失敗しない:

TypeError: Cannot read property 'length' of undefined

明らかにそれはデータが返さされていない、と私はできることを意味します私が選んでいるフィールドは{ "d" : 1 }で、100%保証されており、今まで変更はありませんでした。

大規模なデータセットは、100万を超えるほど、単純にMongoソートを破りますか?アプリケーションを新しく動かすとうまくいきます。テーブルが大きくなり、プログラムが実行されます。参考のため

は、ここにまっすぐに私のデータベースからのサンプルデータセットです:

enter image description here

+0

あなたはどのバージョンのmongodbを使用していますか? –

+0

3.2.1 –

+0

のように見えるこの文書をスニペットから読んだことがありますか? https://docs.mongodb.org/manual/reference/method/cursor.sort/#restrictions...doデータベースログにエラーがありますか? –

答えて

1

thisによると:

When unable to obtain the sort order from an index, MongoDB will sort the results in memory, which requires that the result set being sorted is less than 32 megabytes.

先に行くとあなたの並べ替え(例)のインデックスを作成します。

db.records.createIndex({ a: 1 }) 

またはa limit()

関連する問題