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

Remove unneeded [isArray] check on sharding key

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Minor - P4 Minor - P4
    • 7.1.0-rc0
    • None
    • None
    • None
    • Query Execution
    • Fully Compatible

    Description

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

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: