[SERVER-43176] Restrict SortedDataInterface::seekExact to only return exact KeyString matches Created: 05/Sep/19  Updated: 29/Oct/23  Resolved: 01/Dec/21

Status: Closed
Project: Core Server
Component/s: Index Maintenance
Affects Version/s: None
Fix Version/s: 5.2.0

Type: Improvement Priority: Major - P3
Reporter: Louis Williams Assignee: Louis Williams
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Sprint: Execution Team 2021-11-15, Execution Team 2021-11-29, Execution Team 2021-12-13
Participants:

 Description   

SERVER-42972 allowed seekExact take a KeyString, but implementations really only search for approximate KeyStrings that match a prefix. This is because most indexes (non-_id) append RecordIds to their keys.

We can narrow the scope of the function so that it's semantics are more obvious. That is: only return exact KeyString matches. Don't try to compare without the RecordId just to satisfy the API.

Additionally, IndexAccessMethod::findSingle() is the only caller of SortedDataInterface::seekExact. And index lookups on the _id index are the only callers of findSingle().

For example: all indexes but the _id index store keys as the concatenation of KeyString+RecordId. If I seek with seekExact on the _id index, I simply pass that key to the storage engine and get a match. If I seek with seekExact on a non-_id index, it would be incorrect to ever return a key, because there will never be an exact match unless a RecordID is also part of the seeked-for KeyString (and that is pointless).



 Comments   
Comment by Githook User [ 01/Dec/21 ]

Author:

{'name': 'Henrik Edin', 'email': 'henrik.edin@mongodb.com', 'username': 'henrikedin'}

Message: SERVER-43176 Remove seekExact from SortedDataInterface

This replaces SortedDataInterface::Cursor::seekExact with a findLoc
function on the SortedDataInterface. This has the benefit of being independent
of cursor position and direction.
Branch: master
https://github.com/mongodb/mongo/commit/f01e9aaa0d99f47bc6d96839e4ea3cc1108e715c

Comment by Louis Williams [ 05/Sep/19 ]

This would also allow us to do what I suggested before in SERVER-40176. We would be able to use WT_CURSOR::search instead of search_near

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