[SERVER-79853] [CQF] Generate SBE expression to hash shard key when invoking ShardFilterer Created: 08/Aug/23  Updated: 29/Oct/23  Resolved: 22/Aug/23

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

Type: Task Priority: Major - P3
Reporter: Ben Shteinfeld Assignee: Ben Shteinfeld
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by SERVER-78502 [CQF] Relax M2 CQF fallback (tryBonsa... Closed
Related
Assigned Teams:
Query Optimization
Backwards Compatibility: Fully Compatible
Participants:
Linked BF Score: 145

 Description   

In the enforcer and implementers which handle RemoveOrphansRequirement, we currently generate physical plans that do not consider the collation spec of the shard key. This means for shard keys like {_id: 'hashed'}, if we are performing a coll scan, we need to hash the value of _id before invoking the ShardFilterer.



 Comments   
Comment by Ben Shteinfeld [ 28/Sep/23 ]

sanika.phanse@mongodb.com apologizes for the delay, I am just returning from OOO. This ticket should not be backported and is not related to SERVER-78253, thank you!

Comment by Sanika Phanse (Inactive) [ 27/Sep/23 ]

Hi ben.shteinfeld@mongodb.com Any updates here? So far the feature has been backported to 7.0 and a backport to 6.0 is in-progress.

Comment by Sanika Phanse (Inactive) [ 18/Sep/23 ]

Hi ben.shteinfeld@mongodb.com, I am backporting SERVER-78253 as a part of PM-3493 (to 7.0, 6.0, 5.0), does this ticket need to be backported as well? And if so, which versions should it be backported to?

Comment by Githook User [ 22/Aug/23 ]

Author:

{'name': 'Ben Shteinfeld', 'email': 'ben.shteinfeld@mongodb.com', 'username': 'bshteinfeld'}

Message: SERVER-79853 [CQF] Correctly handle hashed shard keys when performing shard filtering

When a shard key contains a hashed component, the ShardFilterer expects
us to pass it a value which is also hashed. We achieve this by inserting
an invocation of the 'shardHash' SBE builtin function where necessary.

This patch also updates the CQF fallback mechanism to enable CQF for
hashed shard keys when a natural hint is provided and/or there is no
hashed index backing the shard key (this is allowed by SERVER-78253).
Branch: master
https://github.com/mongodb/mongo/commit/694d0aae817b891a3752a9900309c98ce471c5a8

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