The CollectionRoutingInfoTargeter::targetDelete() currently has few inefficiencies that we can improve. Here are a three improvements that we should consider.
1. We should short circuit unsharded deletes at the beginning of the function and avoid parsing the query on mongos. We do this for targetUpdate()
2. We make three different calls to CanonicalQuery::canonicalize() during this function, (1) inside extractShardKeyFromBasicQueryWithContext(), (2) top level of targetDelete() and (3) inside _targetQuery(). We should refactor all of these to use a single CanconicalQuery and ExpressionContext throughout.
3. The "extract shard key from query" is first attempted in extractShardKeyFromBasicQueryWithContext() and then also inside the _targetQuery() ---> getShardIdsForQuery().
I believe targetUpdate() can benefit from similar improvements.
- related to
-
SERVER-86205 Avoid constructing CanonicalQuery twice on mongos
- Closed