[SERVER-42333] Make SortKeyGenerator return KeyString and use KeyString for sort key metadata Created: 22/Jul/19  Updated: 06/Dec/22

Status: Backlog
Project: Core Server
Component/s: Querying
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: David Storch Assignee: Backlog - Query Execution
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on SERVER-41721 IndexAccessMethod::getKeys should ret... Closed
Related
Assigned Teams:
Query Execution
Participants:
Linked BF Score: 0

 Description   

The storage team is planning to make the BtreeKeyGenerator capable of returning index keys formatted as KeyString rather than BSONObj. Once this is done, it should become straightforward to reimplement the SortKeyGenerator, which uses the BtreeKeyGenerator internally, to return a document's sort key as a KeyString. This KeyString format could then be attached in lieu of a BSONObj as a Document's sort key metadata. Since KeyString comparison is cheap, we expect that this should improve the performance for executing blocking sorts in both the find and aggregate commands.

We should also look into using KeyString as the wire format for sort keys. Some query plans require that one node computes a sort key and another later ingests this sort key in order to compute a merge sort (e.g. when each shard returns sorted data, and a mongos needs to merge sort). Using the KeyString as the wire format would make this merge sort cheaper for the merging node to compute, and would avoid any differences between the in-memory and over-the-wire sort key formats.


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