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

Inclusivity of index bounds is not expressed in explain output

    • Fully Compatible

      > c.ensureIndex({a:1})
      > c.find({a:{$gt:5}})
      > c.find({a:{$gt:5}}).explain()
      {
      	"cursor" : "BtreeCursor a_1",
      	"nscanned" : 0,
      	"nscannedObjects" : 0,
      	"n" : 0,
      	"millis" : 7,
      	"nYields" : 0,
      	"nChunkSkips" : 0,
      	"isMultiKey" : false,
      	"indexOnly" : false,
      	"indexBounds" : {
      		"a" : [
      			[
      				5,
      				1.7976931348623157e+308
      			]
      		]
      	}
      }
      > c.find({a:{$gte:5}}).explain()
      {
      	"cursor" : "BtreeCursor a_1",
      	"nscanned" : 0,
      	"nscannedObjects" : 0,
      	"n" : 0,
      	"millis" : 0,
      	"nYields" : 0,
      	"nChunkSkips" : 0,
      	"isMultiKey" : false,
      	"indexOnly" : false,
      	"indexBounds" : {
      		"a" : [
      			[
      				5,
      				1.7976931348623157e+308
      			]
      		]
      	}
      }
      

      With an exclusive bound our btree scanning implementation can avoid scanning every key with a=5, while with an inclusive bound we must scan every key with a=5. However, there is no indication of this from the explain output. I usually mention that this is the case when doing new hire training, and recently it was raised specifically as a usability issue.

            Assignee:
            benety.goh@mongodb.com Benety Goh
            Reporter:
            aaron Aaron Staple
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: