MongoDB:104857600バイトのソートを超えたメモリのソート
コレクション内で大規模な並べ替え操作(集計)を実行し、次のエラーメッセージを表示します。
MongoDBコンソール
> db.bigdata.aggregate(
{$group : {__id : "$range", total : { $sum : 1 }}},
{$sort : {total : -1}}
);
#...
aggregate failed
at Error (<anonymous>)
at doassert (src/mongo/shell/assert.js:11:14)
#...
Error: command failed: {
"errmsg" : "exception: Sort exceeded memory limit of 104857600 bytes,
but did not opt in to external sorting. Aborting operation. Pass allowDiskUse:true to opt in.",
"code" : 16819,
"ok" : 0
}
P.S MongoDB 3.0.6
でテスト済み
解決策
これを修正するには、クエリで `allowDiskUse`オプションを有効にしてください:
db.bigdata.aggregate([ {$group : {__id : "$range", total : { $sum : 1 }}},
{$sort : {total : -1}}],
{allowDiskUse: true}
);
参考文献
外部ソートによる大規模ソート操作]。
http://docs.mongodb.org/manual/core/aggregation-pipeline-limits/#agg-memory-restrictions
[Aggregation
パイプラインの制限]。リンク://mongodb/mongodb-aggregate-and-group-example/[MongoDB –
集計とグループの例]