Skip to content

Instantly share code, notes, and snippets.

@RedBeard0531
Created November 29, 2010 17:16
Show Gist options
  • Save RedBeard0531/720237 to your computer and use it in GitHub Desktop.
Save RedBeard0531/720237 to your computer and use it in GitHub Desktop.
> db.foo.ensureIndex({a:1})
> db.foo.ensureIndex({b:1})
> db.foo.insert({a:1})
> db.foo.insert({b:1})
> db.foo.insert({a:1, b:1})
> db.foo.find({$or:[{a:1}, {b:1}]}).explain()
{
"clauses" : [
{
"cursor" : "BtreeCursor a_1",
"nscanned" : 2,
"nscannedObjects" : 2,
"n" : 2,
"millis" : 0,
"nYields" : 0,
"nChunkSkips" : 0,
"isMultiKey" : false,
"indexOnly" : false,
"indexBounds" : {
"a" : [
[
1,
1
]
]
},
"allPlans" : [
{
"cursor" : "BtreeCursor a_1",
"indexBounds" : {
"a" : [
[
1,
1
]
]
}
}
]
},
{
"cursor" : "BtreeCursor b_1",
"nscanned" : 2,
"nscannedObjects" : 2,
"n" : 1,
"millis" : 0,
"nYields" : 0,
"nChunkSkips" : 0,
"isMultiKey" : false,
"indexOnly" : false,
"indexBounds" : {
"b" : [
[
1,
1
]
]
},
"allPlans" : [
{
"cursor" : "BtreeCursor b_1",
"indexBounds" : {
"b" : [
[
1,
1
]
]
}
}
]
}
],
"nscanned" : 4,
"nscannedObjects" : 4,
"n" : 3,
"millis" : 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment