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

Avoid sorting $in list when it gets converted to KeyString

    • Type: Icon: Task Task
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Query Optimization
    • QO 2024-02-05, QO 2024-02-19, QO 2024-03-04, QO 2024-03-18, QO 2024-04-01, QO 2024-04-15, QO 2024-04-29

      Often we will sort the BSON elements of a $in list early in query processing. Sorting BSON elements is usually fairly slow, and for short running query, this takes a significant amount of the runtime.

       

      Sometimes, this $in list gets converted to KeyStrings, which are used for index bounds. KeyStrings are very easy/fast to compare, so we should try to delay the sorting of the $in list elements until after the KeyStrings are generated.

       

      This will not be possible in all cases, but should be a minor perf win for $in queries that get answered with ixscan/fetch plans. For example, a query that fetches a bunch of documents via a $in on _id.

            Assignee:
            Unassigned Unassigned
            Reporter:
            ian.boros@mongodb.com Ian Boros
            Votes:
            1 Vote for this issue
            Watchers:
            12 Start watching this issue

              Created:
              Updated: