Skip to content

Instantly share code, notes, and snippets.

@ptz0n
Created July 4, 2013 15:55
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 ptz0n/5928784 to your computer and use it in GitHub Desktop.
Save ptz0n/5928784 to your computer and use it in GitHub Desktop.
MongoDB $in + sort() query
> db.mydocs.find({_id: {$in: [ObjectId("51be3ca24cc1682a13000003"), ObjectId("51be3c3b2799560d13000003")]}}).sort({'published': 1}).explain();
{
"cursor" : "BtreeCursor _id_ multi",
"nscanned" : 2,
"nscannedObjects" : 2,
"n" : 2,
"scanAndOrder" : true,
"millis" : 0,
"nYields" : 0,
"nChunkSkips" : 0,
"isMultiKey" : false,
"indexOnly" : false,
"indexBounds" : {
"_id" : [
[
ObjectId("51be3c3b2799560d13000003"),
ObjectId("51be3c3b2799560d13000003")
],
[
ObjectId("51be3ca24cc1682a13000003"),
ObjectId("51be3ca24cc1682a13000003")
]
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment