Created
May 8, 2014 19:05
-
-
Save garrilla/a59dcc992e61f2ba3808 to your computer and use it in GitHub Desktop.
MongoDB shell use of aggregate [broke]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 } | |
} | |
} | |
)} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
im building a script to do some benchmarking for various approaches to aggregation