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

Remove unneeded [isArray] check on sharding key

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • 7.1.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Query Execution
    • Fully Compatible

      In sbe_stage_builders.cpp, there is a point during the creation of the SBE plan in which we need to create a plan to retrieve the shard key in order to create the ShardFilterer. At this point, we add anĀ if expression which makes sure that the shard key is not an array. However, this check is not needed and adds an extra stage to the plan because writing an array to the shard key is already prohibited, so this scenario will never arise.

      Example SBE plan generated by using find() on a sharded collection with shard key "x":

      "slotBasedPlan":{    
      "slots": ...
      "stages":
      "[2] filter {    
      let [        l1.0 = (s6 ?: null)     ]     in 
      shardFilter(s5, 
           if isArray(l1.0) then Nothing else // This part is not needed 
          makeBsonObj(MakeObjSpec(drop, [], [\"x\"]), Nothing, l1.0) // spec,  root, projection values   ) } ...

            Assignee:
            ivan.fefer@mongodb.com Ivan Fefer
            Reporter:
            richard.hausman@mongodb.com Richard Hausman (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: