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

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

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor - P4
    • Resolution: Fixed
    • 2.6.0-rc0
    • 2.6.0-rc1
    • Querying
    • None
    • Fully Compatible
    • ALL

    Description

      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".

      Attachments

        Issue Links

          Activity

            People

              benety.goh@mongodb.com Benety Goh
              david.storch@mongodb.com David Storch
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: