-
-
Save cank/0c9b9b74655ddab7f820 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// First query. Notice n = 6758. The second OR condition by definition includes the first. | |
> db.contacts.find( | |
... { | |
... | |
... $or: [ | |
... {'foo': 32} | |
... ,{'foo': 32, 'bar' : 151629} | |
... ] | |
... } | |
... ).explain(); | |
{ | |
"cursor" : "BtreeCursor foo_1_bar_1", | |
"nscanned" : 6758, | |
"nscannedObjects" : 6758, | |
"n" : 6758, | |
"millis" : 7, | |
"nYields" : 0, | |
"nChunkSkips" : 0, | |
"isMultiKey" : false, | |
"indexOnly" : false, | |
"indexBounds" : { | |
"foo" : [ | |
[ | |
32, | |
32 | |
] | |
], | |
"bar" : [ | |
[ | |
{ | |
"$minElement" : 1 | |
}, | |
{ | |
"$maxElement" : 1 | |
} | |
] | |
] | |
} | |
} | |
// Second query. Notice n = 6761. | |
> db.contacts.find( | |
... { | |
... | |
... $or: [ | |
... {'foo': 32, 'bar' : 151629}, | |
... {'foo': 32} | |
... ] | |
... } | |
... ).explain(); | |
{ | |
"clauses" : [ | |
{ | |
"cursor" : "BtreeCursor foo_1_bar_1", | |
"nscanned" : 3, | |
"nscannedObjects" : 3, | |
"n" : 3, | |
"millis" : 0, | |
"nYields" : 0, | |
"nChunkSkips" : 0, | |
"isMultiKey" : false, | |
"indexOnly" : false, | |
"indexBounds" : { | |
"foo" : [ | |
[ | |
32, | |
32 | |
] | |
], | |
"bar" : [ | |
[ | |
151629, | |
151629 | |
] | |
] | |
} | |
}, | |
{ | |
"cursor" : "BtreeCursor foo_1_bar_1", | |
"nscanned" : 6758, | |
"nscannedObjects" : 6758, | |
"n" : 6755, | |
"millis" : 33, | |
"nYields" : 0, | |
"nChunkSkips" : 0, | |
"isMultiKey" : false, | |
"indexOnly" : false, | |
"indexBounds" : { | |
"foo" : [ | |
[ | |
32, | |
32 | |
] | |
], | |
"bar" : [ | |
[ | |
{ | |
"$minElement" : 1 | |
}, | |
{ | |
"$maxElement" : 1 | |
} | |
] | |
] | |
} | |
} | |
], | |
"nscanned" : 6761, | |
"nscannedObjects" : 6761, | |
"n" : 6758, | |
"millis" : 33 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment