Skip to content

Instantly share code, notes, and snippets.

@garrilla
Created May 8, 2014 19:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save garrilla/a59dcc992e61f2ba3808 to your computer and use it in GitHub Desktop.
Save garrilla/a59dcc992e61f2ba3808 to your computer and use it in GitHub Desktop.
MongoDB shell use of aggregate [broke]
var eachN1byAggregate = function(){
print('Counting each \'n1\' in Main');
conn = new Mongo();
db = conn.getDB("beta3");
print('.. preparing to count');
start = Date.now();
n1_count = getAggregate();
end = Date.now();
elapsed2 = (end - start)/1000;
print('Count completed in '+elapsed2+' secs.');
printjson(n1_count);
function getAggregate() { return db.main.aggregate(
{
$group: {
_id: "$n1",
n1cnt : { $sum : 1 }
}
}
)}
}
@garrilla
Copy link
Author

garrilla commented May 8, 2014

im building a script to do some benchmarking for various approaches to aggregation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment