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

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.3.9
    • Component/s: Diagnostics, Querying
    • Labels:
    • Backwards Compatibility:
      Fully Compatible
    • Sprint:
      Query 16 (06/24/16)

      Description

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

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated:
              Resolved: