explain should re-run all plans for that query but NOT mutate the cache

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Minor - P4
    • 2.6.0-rc1
    • Affects Version/s: 2.6.0-rc0
    • Component/s: Querying
    • None
    • Fully Compatible
    • ALL
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None

      New semantics for explain():

      explain should re-run all plans for that query but NOT mutate the cache.

      ----------

      In a full explain, the "allPlans" field can report the index bounds used when the query shape was cached. This is misleading, as it appears that some of the alternative plans used the wrong index bounds:

      > t = db.t
      test.t
      > t.drop()
      true
      > t.ensureIndex({a: 1})
      WriteResult({ "nInserted" : 1 })
      > t.ensureIndex({a: 1, b: 1})
      WriteResult({ "nInserted" : 1 })
      > t.find({a: "foo"}).explain()
      {
      	"cursor" : "BtreeCursor a_1",
      	"isMultiKey" : false,
      	"n" : 0,
      	"nscannedObjects" : 0,
      	"nscanned" : 0,
      	"nscannedObjectsAllPlans" : 0,
      	"nscannedAllPlans" : 0,
      	"scanAndOrder" : false,
      	"indexOnly" : false,
      	"nYields" : 0,
      	"nChunkSkips" : 0,
      	"millis" : 1,
      	"indexBounds" : {
      		"a" : [
      			[
      				"foo",
      				"foo"
      			]
      		]
      	},
      	"server" : "localhost:27017",
      	"filterSet" : false
      }
      > t.find({a: "bar"}).explain(true)
      {
      	"cursor" : "BtreeCursor a_1",
      	"isMultiKey" : false,
      	"n" : 0,
      	"nscannedObjects" : 0,
      	"nscanned" : 0,
      	"nscannedObjectsAllPlans" : 0,
      	"nscannedAllPlans" : 0,
      	"scanAndOrder" : false,
      	"indexOnly" : false,
      	"nYields" : 0,
      	"nChunkSkips" : 0,
      	"millis" : 0,
      	"indexBounds" : {
      		"a" : [
      			[
      				"bar",
      				"bar"
      			]
      		]
      	},
      	"allPlans" : [
      		{
      			"cursor" : "BtreeCursor a_1",
      			"isMultiKey" : false,
      			"n" : 0,
      			"nscannedObjects" : 0,
      			"nscanned" : 0,
      			"scanAndOrder" : false,
      			"indexOnly" : false,
      			"nChunkSkips" : 0,
      			"indexBounds" : {
      				"a" : [
      					[
      						"bar",
      						"bar"
      					]
      				]
      			}
      		},
      		{
      			"cursor" : "BtreeCursor a_1_b_1",
      			"isMultiKey" : false,
      			"n" : 0,
      			"nscannedObjects" : 0,
      			"nscanned" : 0,
      			"scanAndOrder" : false,
      			"indexOnly" : false,
      			"nChunkSkips" : 0,
      			"indexBounds" : {
      				"a" : [
      					[
      						"foo",
      						"foo"
      					]
      				],
      				"b" : [
      					[
      						{
      							"$minElement" : 1
      						},
      						{
      							"$maxElement" : 1
      						}
      					]
      				]
      			}
      		},
      		{
      			"cursor" : "BasicCursor",
      			"isMultiKey" : false,
      			"n" : 0,
      			"nscannedObjects" : 0,
      			"nscanned" : 0,
      			"scanAndOrder" : false,
      			"indexOnly" : false,
      			"nChunkSkips" : 0
      		}
      	],
      	"server" : "localhost:27017",
      	"filterSet" : false,
      	"stats" : {
      

      In the above example, the second plan reported in "allPlans" reports index bounds using "foo" rather than "bar".

            Assignee:
            Benety Goh
            Reporter:
            David Storch
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: