Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-4164

Compound key index bounds for an array of documents seem wrong

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.0.1
    • Component/s: Index Maintenance
    • None
    • ALL

      This is related to http://groups.google.com/group/mongodb-user/browse_thread/thread/9f08de0b3c3e1a13

      Explain shows correct bounds for a query on an array of documents if the array only includes one document:

      PRIMARY> db.foo.ensureIndex({'aH.s': 1, 'aH.m': 1, 'aH.u': 1})
      PRIMARY> db.foo.insert({aH: [{s: 'a', m: 'b', u: 'c'}]})
      PRIMARY> db.foo.find({'aH.s': 'x', 'aH.m': 'y', 'aH.u': 'z'}).explain()
      {
      	"cursor" : "BtreeCursor aH.s_1_aH.m_1_aH.u_1",
      	"nscanned" : 0,
      	"nscannedObjects" : 0,
      	"n" : 0,
      	"millis" : 0,
      	"nYields" : 0,
      	"nChunkSkips" : 0,
      	"isMultiKey" : false,
      	"indexOnly" : false,
      	"indexBounds" : {
      		"aH.s" : [
      			[
      				"x",
      				"x"
      			]
      		],
      		"aH.m" : [
      			[
      				"y",
      				"y"
      			]
      		],
      		"aH.u" : [
      			[
      				"z",
      				"z"
      			]
      		]
      	}
      }
      

      If you then insert another document that has more than one document in the array the bounds listed by explain seem wrong:

      PRIMARY> db.foo.insert({aH: [{s: 'd', m: 'e', u: 'f'}, {s: 'g', m: 'h', u: 'i'}]})
      PRIMARY> db.foo.find({'aH.s': 'x', 'aH.m': 'y', 'aH.u': 'z'}).explain()
      {
      	"cursor" : "BtreeCursor aH.s_1_aH.m_1_aH.u_1",
      	"nscanned" : 0,
      	"nscannedObjects" : 0,
      	"n" : 0,
      	"millis" : 0,
      	"nYields" : 0,
      	"nChunkSkips" : 0,
      	"isMultiKey" : true,
      	"indexOnly" : false,
      	"indexBounds" : {
      		"aH.s" : [
      			[
      				"x",
      				"x"
      			]
      		],
      		"aH.m" : [
      			[
      				{
      					"$minElement" : 1
      				},
      				{
      					"$maxElement" : 1
      				}
      			]
      		],
      		"aH.u" : [
      			[
      				{
      					"$minElement" : 1
      				},
      				{
      					"$maxElement" : 1
      				}
      			]
      		]
      	}
      }
      

            Assignee:
            eliot Eliot Horowitz (Inactive)
            Reporter:
            bernie@mongodb.com Bernie Hackett
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: