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

COUNT_SCAN query execution stage does not report index bounds in execution stats output for explain

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.3.9
    • Affects Version/s: None
    • Component/s: Diagnostics, Querying
    • Labels:
    • Fully Compatible
    • Query 16 (06/24/16)

      The execution stats output for explain of a query plan containing the COUNT_SCAN execution stage is missing index bounds information. The other index access stages correctly report their associated index bounds.

      > db.foo.drop()
      true
      > db.foo.ensureIndex({a:1})
      {
      	"createdCollectionAutomatically" : true,
      	"numIndexesBefore" : 1,
      	"numIndexesAfter" : 2,
      	"ok" : 1
      }
      > db.foo.explain('executionStats').find({a:1})  // Index bounds correctly reported.
      ...
      				"stage" : "IXSCAN",
      				"nReturned" : 0,
      				"executionTimeMillisEstimate" : 0,
      				"works" : 1,
      				"advanced" : 0,
      				"needTime" : 0,
      				"needYield" : 0,
      				"saveState" : 0,
      				"restoreState" : 0,
      				"isEOF" : 1,
      				"invalidates" : 0,
      				"keyPattern" : {
      					"a" : 1
      				},
      				"indexName" : "a_1",
      				"isMultiKey" : false,
      				"isUnique" : false,
      				"isSparse" : false,
      				"isPartial" : false,
      				"indexVersion" : 1,
      				"direction" : "forward",
      				"indexBounds" : {
      					"a" : [
      						"[1.0, 1.0]"
      					]
      				},
      ...
      > db.foo.explain('executionStats').distinct('a') // Index bounds correctly reported.
      ...
      				"stage" : "DISTINCT_SCAN",
      				"nReturned" : 0,
      				"executionTimeMillisEstimate" : 0,
      				"works" : 1,
      				"advanced" : 0,
      				"needTime" : 0,
      				"needYield" : 0,
      				"saveState" : 0,
      				"restoreState" : 0,
      				"isEOF" : 1,
      				"invalidates" : 0,
      				"keyPattern" : {
      					"a" : 1
      				},
      				"indexName" : "a_1",
      				"isMultiKey" : false,
      				"isUnique" : false,
      				"isSparse" : false,
      				"isPartial" : false,
      				"indexVersion" : 1,
      				"direction" : "forward",
      				"indexBounds" : {
      					"a" : [
      						"[MinKey, MaxKey]"
      					]
      				},
      ...
      > db.foo.explain('executionStats').count({a:1}) // Index bounds not reported.
      ...
      			"inputStage" : {
      				"stage" : "COUNT_SCAN",
      				"nReturned" : 0,
      				"executionTimeMillisEstimate" : 0,
      				"works" : 1,
      				"advanced" : 0,
      				"needTime" : 0,
      				"needYield" : 0,
      				"saveState" : 0,
      				"restoreState" : 0,
      				"isEOF" : 1,
      				"invalidates" : 0,
      				"keysExamined" : 1,
      				"keyPattern" : {
      					"a" : 1
      				},
      				"indexName" : "a_1",
      				"isMultiKey" : false,
      				"isUnique" : false,
      				"isSparse" : false,
      				"isPartial" : false,
      				"indexVersion" : 1
      			}
      ...
      

            Assignee:
            david.hatch David Hatch
            Reporter:
            rassi J Rassi
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: