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

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: In Progress
    • Major - P3
    • Resolution: Unresolved
    • None
    • None
    • Querying
    • Query Optimization
    • QO 2023-03-06, QO 2023-03-20, QO 2023-04-03

    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

              milena.ivanova@mongodb.com Milena Ivanova
              alex.komyagin@mongodb.com Alexander Komyagin
              Votes:
              13 Vote for this issue
              Watchers:
              41 Start watching this issue

              Dates

                Created:
                Updated: