[SERVER-78541] Remove unneeded [isArray] check on sharding key Created: 29/Jun/23 Updated: 29/Oct/23 Resolved: 09/Aug/23 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 7.1.0-rc0 |
| Type: | Improvement | Priority: | Minor - P4 |
| Reporter: | Richard Hausman (Inactive) | Assignee: | Ivan Fefer |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Assigned Teams: |
Query Execution
|
| Backwards Compatibility: | Fully Compatible |
| Participants: |
| 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":
|
| Comments |
| Comment by Githook User [ 09/Aug/23 ] |
|
Author: {'name': 'Ivan Fefer', 'email': 'ivan.fefer@mongodb.com', 'username': 'Fefer-Ivan'}Message: |
| Comment by Ivan Fefer [ 08/Aug/23 ] |
|
Currently the generated SBE code is written to mimic the behavior of ShardKeyPattern::extractShardKeyFromDocumentKey This function returns empty BSONObj in case it finds an array. SBE code returns Nothing. Now, when SBE is used only for reads, we can omit IsArray, but in the future, when we may encounter this code for writes, we should not forget to support possible arrays. |