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

New explain mode "listPlans"

    • Type: Icon: New Feature New Feature
    • Resolution: Unresolved
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: Querying
    • Labels:
      None
    • Query Optimization

      Currently there are three explain modes:

      • queryPlanner - generates plans, selects the best one
      • executionStats - generates plans, selects the best one, runs the winner and reports on its execution
      • allPlansExecution - generates plans, selects the best one, runs the winner, reports on the execution of the winner and the losing candidate plans

      I propose adding a fourth mode called "listPlans". This mode would generate candidate plans, but do nothing more. It will not perform plan selection, and therefore cannot tell you which plan will be executed. However, it would run almost instantaneously because it does not need to use the query execution machinery at all.

      Example:

      > db.test.find({a: 1}).explain("listPlans")
      {
      	"queryPlanner" : {
      		"plannerVersion" : 1,
      		"namespace" : "test.test",
      		"indexFilterSet" : false,
      		"parsedQuery" : {
      			"a" : {
      				"$eq" : 1
      			}
      		},
      		"plans" : [
               {
      			"stage" : "FETCH",
      			"inputStage" : {
      				"stage" : "IXSCAN",
      				"keyPattern" : {
      					"a" : 1
      				},
      				"indexName" : "a_1",
      				"isMultiKey" : false,
      				"direction" : "forward",
      				"indexBounds" : {
      					"a" : [
      						"[1.0, 1.0]"
      					]
      				}
      			}
      		},
              {
      			"stage" : "FETCH",
      			"inputStage" : {
      				"stage" : "IXSCAN",
      				"keyPattern" : {
      					"a" : 1, 
                          "b":  1
      				},
      				"indexName" : "a_1_b_1",
      				"isMultiKey" : false,
      				"direction" : "forward",
      				"indexBounds" : {
      					"a" : [
      						"[1.0, 1.0]"
      					],
      					"b" : [
      						"[MinKey, MaxKey]"
      					]
      				}
      			}
      		}]
      	},
      	"serverInfo" : {
      		"host" : "dstorch-desktop",
      		"port" : 27017,
      		"version" : "2.8.0-rc6-pre-",
      		"gitVersion" : "89ddf2d90625a7738b8e48dce1a5776942603d27"
      	},
      	"ok" : 1
      }
      

            Assignee:
            backlog-query-optimization [DO NOT USE] Backlog - Query Optimization
            Reporter:
            david.storch@mongodb.com David Storch
            Votes:
            5 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated: