Skip to content

Instantly share code, notes, and snippets.

@eliwjones
Created August 24, 2011 00:11
Show Gist options
  • Save eliwjones/1166973 to your computer and use it in GitHub Desktop.
Save eliwjones/1166973 to your computer and use it in GitHub Desktop.
mongodb Compound Index query wierdness.
mydb:PRIMARY> db.mycollection.find({propOne:869}).explain()
{
"cursor" : "BtreeCursor propOne_1_propTwo_1_propThree_1",
"nscanned" : 8889642,
"nscannedObjects" : 8889642,
"n" : 804382,
"millis" : 11683,
"nYields" : 152,
"nChunkSkips" : 0,
"isMultiKey" : true,
"indexOnly" : false,
"indexBounds" : {
"propOne" : [
[
869,
869
]
],
"propTwo" : [
[
{
"$minElement" : 1
},
{
"$maxElement" : 1
}
]
],
"propThree" : [
[
{
"$minElement" : 1
},
{
"$maxElement" : 1
}
]
]
}
}
mydb:PRIMARY> db.mycollection.find({propOne:869, propTwo:"my string name"}).explain()
{
"cursor" : "BtreeCursor propOne_1_propTwo_1_propThree_1",
"nscanned" : 232225,
"nscannedObjects" : 232225,
"n" : 232225,
"millis" : 381,
"nYields" : 4,
"nChunkSkips" : 0,
"isMultiKey" : true,
"indexOnly" : false,
"indexBounds" : {
"propOne" : [
[
869,
869
]
],
"propTwo" : [
[
"my string name",
"my string name"
]
],
"propThree" : [
[
{
"$minElement" : 1
},
{
"$maxElement" : 1
}
]
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment