Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- db.ensureIndex( { 'a.b':1, 'a.c':1 } );
- ------------------------------------------------------------------
- Mongo > db.version()
- 2.4.1
- Mongo > db.test.find({ a:{ $elemMatch:{ b:1, c:20 } } } ).explain() // index bound works perfectly
- {
- "cursor" : "BtreeCursor a.b_1_a.c_1",
- "isMultiKey" : true,
- "n" : 0,
- "nscannedObjects" : 0,
- "nscanned" : 0,
- "nscannedObjectsAllPlans" : 0,
- "nscannedAllPlans" : 0,
- "scanAndOrder" : false,
- "indexOnly" : false,
- "nYields" : 0,
- "nChunkSkips" : 0,
- "millis" : 0,
- "indexBounds" : {
- "a.b" : [
- [
- 1,
- 1
- ]
- ],
- "a.c" : [
- [
- 20,
- 20
- ]
- ]
- },
- "server" : "bdvlpabhishekk:27016"
- }
- ------------------------------------------------------------------
- Mongo > db.version()
- 2.2.0
- Mongo > db.test2.find({ a:{ $elemMatch:{ b:1, c:20 } } } ).explain() // check the index bound, not working as expected
- {
- "cursor" : "BtreeCursor a.b_1_a.c_1",
- "isMultiKey" : true,
- "n" : 0,
- "nscannedObjects" : 1,
- "nscanned" : 1,
- "nscannedObjectsAllPlans" : 1,
- "nscannedAllPlans" : 1,
- "scanAndOrder" : false,
- "indexOnly" : false,
- "nYields" : 0,
- "nChunkSkips" : 0,
- "millis" : 0,
- "indexBounds" : {
- "a.b" : [
- [
- 1,
- 1
- ]
- ],
- "a.c" : [
- [
- {
- "$minElement" : 1
- },
- {
- "$maxElement" : 1
- }
- ]
- ]
- },
- "server" : "bdvlpabhishekk:27017"
- }
- ---------------------
- Mongo > db.version()
- 2.4.1
- Mongo > db.test.find( { 'a.b':1, 'a.c':2 } ).explain() // check the index bounds, not working as expected
- {
- "cursor" : "BtreeCursor a.b_1_a.c_1",
- "isMultiKey" : true,
- "n" : 1,
- "nscannedObjects" : 1,
- "nscanned" : 1,
- "nscannedObjectsAllPlans" : 1,
- "nscannedAllPlans" : 1,
- "scanAndOrder" : false,
- "indexOnly" : false,
- "nYields" : 0,
- "nChunkSkips" : 0,
- "millis" : 0,
- "indexBounds" : {
- "a.b" : [
- [
- 1,
- 1
- ]
- ],
- "a.c" : [
- [
- {
- "$minElement" : 1
- },
- {
- "$maxElement" : 1
- }
- ]
- ]
- },
- "server" : "bdvlpabhishekk:27016"
- }
- ------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment