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

Partial index shouldn't do fetch on conditions that are true by the definition of the index

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Major - P3
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: Backlog
    • Component/s: Querying
    • Labels:
    • Case:

      Description

      db.xxx.ensureIndex({x:1},{partialFilterExpression:{bin:true}})
      

      > db.xxx.find({bin:true,x:1}).explain()
      {
      	"queryPlanner" : {
      		"plannerVersion" : 1,
      		"namespace" : "test.xxx",
      		"indexFilterSet" : false,
      		"parsedQuery" : {
      			"$and" : [
      				{"bin" : {"$eq" : true}},
      				{"x" : {"$eq" : 1}}
      			]
      		},
      		"winningPlan" : {
      			"stage" : "FETCH",
      			"filter" : {"bin" : {"$eq" : true}},
      			"inputStage" : {
      				"stage" : "IXSCAN",
      				"keyPattern" : {"x" : 1},
      				"indexName" : "x_1",
      				"isMultiKey" : false,
      				"multiKeyPaths" : { "x" : [ ] },
      				"isUnique" : false,
      				"isSparse" : false,
      				"isPartial" : true,
      				"indexVersion" : 2,
      				"direction" : "forward",
      				"indexBounds" : { "x" : [ "[1.0, 1.0]" 	] }
      			}
      		},
      		"rejectedPlans" : [ ]
      	},
      	"serverInfo" : {
      		"host" : "AD-MAC10G.local",
      		"port" : 27017,
      		"version" : "3.4.2",
      		"gitVersion" : "3f76e40c105fc223b3e5aac3e20dcd026b83b38b"
      	},
      	"ok" : 1
      }
      

      There's no need to do the FETCH with a check on bin:true since that condition is already satisfied by the index partial filterexpression

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                5 Vote for this issue
                Watchers:
                22 Start watching this issue

                Dates

                • Created:
                  Updated: