Skip to content

Instantly share code, notes, and snippets.

@mehdimehdi
Created December 13, 2011 07:38
Show Gist options
  • Save mehdimehdi/1471096 to your computer and use it in GitHub Desktop.
Save mehdimehdi/1471096 to your computer and use it in GitHub Desktop.
test mongo
mehdi-ait-oufkirs-MacBook-Air:more_mongo_test mehdi$ cat timeop.js
var collectionName = "activity";
var startTime = new Date();
var docs = db[collectionName].find({publisher_id:17,date_created:{'$gte':new Date(2011,10,13) },points:{'$ne':0}});
docs.forEach(function(doc) {
/*print(doc);*/
});
var endTime = new Date();
print(endTime - startTime);
mehdi-ait-oufkirs-MacBook-Air:more_mongo_test mehdi$ mongo dbh20.mongolab.com:27207/punchtab_slave -u web -p
MongoDB shell version: 1.8.2
Enter password:
connecting to: dbh20.mongolab.com:27207/punchtab_slave
> db.activity.find({publihser_id:17,date_created:{'gte':new Date(2011,10,13)},points:{'$ne':0}}).explain()
{
"cursor" : "BtreeCursor date_created_-1_points_1 multi",
"nscanned" : 0,
"nscannedObjects" : 0,
"n" : 0,
"millis" : 153,
"nYields" : 0,
"nChunkSkips" : 0,
"isMultiKey" : false,
"indexOnly" : false,
"indexBounds" : {
"date_created" : [
[
{
"gte" : ISODate("2011-11-13T08:00:00Z")
},
{
"gte" : ISODate("2011-11-13T08:00:00Z")
}
]
],
"points" : [
[
{
"$minElement" : 1
},
0
],
[
0,
{
"$maxElement" : 1
}
]
]
}
}
> exit
bye
mehdi-ait-oufkirs-MacBook-Air:more_mongo_test mehdi$ mongo dbh20.mongolab.com:27207/punchtab_slave -u web -p XXX timeop.js
MongoDB shell version: 1.8.2
connecting to: dbh20.mongolab.com:27207/punchtab_slave
3549
mehdi-ait-oufkirs-MacBook-Air:more_mongo_test mehdi$
mehdi-ait-oufkirs-MacBook-Air:more_mongo_test mehdi$ cat timeop.js
var collectionName = "activity";
var startTime = new Date();
var docs = db[collectionName].find({publisher_id:17,date_created:{'$gte':new Date(2011,10,13) }});
docs.forEach(function(doc) {
/*print(doc);*/
});
var endTime = new Date();
print(endTime - startTime);
mehdi-ait-oufkirs-MacBook-Air:more_mongo_test mehdi$ mongo dbh20.mongolab.com:27207/punchtab_slave -u web -p wr4p5 timeop.js
MongoDB shell version: 1.8.2
connecting to: dbh20.mongolab.com:27207/punchtab_slave
10418
mehdi-ait-oufkirs-MacBook-Air:more_mongo_test mehdi$ mongo dbh20.mongolab.com:27207/punchtab_slave -u web -p
MongoDB shell version: 1.8.2
Enter password:
connecting to: dbh20.mongolab.com:27207/punchtab_slave
> db.activity.find({publihser_id:17,date_created:{'gte':new Date(2011,10,13)}}).explain()
{
"cursor" : "BtreeCursor date_created_-1_points_1",
"nscanned" : 0,
"nscannedObjects" : 0,
"n" : 0,
"millis" : 0,
"nYields" : 0,
"nChunkSkips" : 0,
"isMultiKey" : false,
"indexOnly" : false,
"indexBounds" : {
"date_created" : [
[
{
"gte" : ISODate("2011-11-13T08:00:00Z")
},
{
"gte" : ISODate("2011-11-13T08:00:00Z")
}
]
],
"points" : [
[
{
"$minElement" : 1
},
{
"$maxElement" : 1
}
]
]
}
}
> exit
bye
mehdi-ait-oufkirs-MacBook-Air:more_mongo_test mehdi$ mongo dbh20.mongolab.com:27207/punchtab_slave -u web -p XXXX timeop.js
MongoDB shell version: 1.8.2
connecting to: dbh20.mongolab.com:27207/punchtab_slave
6298
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment