-
Type: Improvement
-
Resolution: Fixed
-
Priority: Minor - P4
-
Affects Version/s: None
-
Component/s: None
-
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 ) } ...