|
Observed behavior: There is no bound on the amount of memory used by $group.
Expected behavior: $group errors out if it consumes over 10% of physical ram (the same behavior as $sort).
Test
c = db.c;
|
c.drop();
|
|
big = new Array( 10000 + 1 ).toString();
|
|
for( i = 0; i < 100000; ++i ) {
|
c.save( { a:i, b:big } );
|
}
|
|
// Errs out due to running out of memory.
|
printjson( c.aggregate( { $sort:{ a:1 } }, { $limit:1 } ) );
|
|
// Does not err out.
|
printjson( c.aggregate( { $group:{ _id:'$a', c:{ $addToSet:'$b' } } }, { $limit:1 } ) );
|
|