[SERVER-76703] Rework targetDelete() to use a single CanonicalQuery Created: 29/Apr/23  Updated: 05/Feb/24  Resolved: 10/Jul/23

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 7.1.0-rc0

Type: Improvement Priority: Major - P3
Reporter: Arun Banala Assignee: Sebastien Mendez
Resolution: Fixed Votes: 0
Labels: neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-86205 Avoid constructing CanonicalQuery twi... Backlog
Assigned Teams:
Query Execution
Backwards Compatibility: Fully Compatible
Sprint: QE 2023-06-26, QE 2023-07-10, QE 2023-07-24
Participants:

 Description   

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.



 Comments   
Comment by Githook User [ 10/Jul/23 ]

Author:

{'name': 'Sebastien Mendez', 'email': 'sebastien.mendez@mongodb.com', 'username': 'rakiz'}

Message: SERVER-76703 Rework targetDelete and targetUpdate to use a single CanonicalQuery
Branch: master
https://github.com/mongodb/mongo/commit/964963886dd3004e3e48f0de5de4d743344cbd28

Generated at Thu Feb 08 06:33:22 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.