Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-42333

Make SortKeyGenerator return KeyString and use KeyString for sort key metadata

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Querying
    • None
    • Query Execution
    • 0

      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.

            Assignee:
            backlog-query-execution [DO NOT USE] Backlog - Query Execution
            Reporter:
            david.storch@mongodb.com David Storch
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: