Skip to content

Instantly share code, notes, and snippets.

@tobowers
Forked from anonymous/weirdness.js
Created December 20, 2012 21:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tobowers/4348854 to your computer and use it in GitHub Desktop.
Save tobowers/4348854 to your computer and use it in GitHub Desktop.
> db.interactions.find({kind: {$in: [1]}}).sort({$natural: -1}).explain()
{
"cursor" : "ReverseCursor",
"isMultiKey" : false,
"n" : 0,
"nscannedObjects" : 1,
"nscanned" : 1,
"nscannedObjectsAllPlans" : 1,
"nscannedAllPlans" : 1,
"scanAndOrder" : false,
"indexOnly" : false,
"nYields" : 0,
"nChunkSkips" : 0,
"millis" : 0,
"indexBounds" : {
},
"server" : "ip-10-122-57-187:27017"
}
db.interactions.find({kind: {$in: [1]}}).sort({$natural: 1}).explain()
{
"cursor" : "BasicCursor",
"isMultiKey" : false,
"n" : 1,
"nscannedObjects" : 2,
"nscanned" : 2,
"nscannedObjectsAllPlans" : 2,
"nscannedAllPlans" : 2,
"scanAndOrder" : false,
"indexOnly" : false,
"nYields" : 0,
"nChunkSkips" : 0,
"millis" : 0,
"indexBounds" : {
},
"server" : "ip-10-122-57-187:27017"
}
db.interactions.find({kind: {$in: [1]}}).sort({$natural: -1}).hasNext()
false
> db.interactions.find({kind: {$in: [1]}}).sort({$natural: 1}).hasNext()
true
> db.interactions.find({kind: {$in: [1]}}).sort({$natural: -1}).count()
1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment