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

Avoid linear lookup for allowed indexes in applyQuerySettings()

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

      As part of SERVER-79181 QuerySettings are now applied to the query, before planning is performed.

      applyQuerySettings() looks at the index hints for the given collection and then removes all of the indexes, which are not present in the settings.indexHints.allowedIndexes list.

      Currently, this is done as a for loop over all of the indexes and an additional for loop over all of the hints, however, this could be speed up by doing a hash set lookup into set of all allowed index names and set of allowed index patterns. This approach has already been employed by index filters mechanism (https://github.com/mongodb/mongo/blob/965ec692dedf1f1bebad2c28ba54d9f21a9d25ea/src/mongo/db/query/get_executor.cpp#L207)

      This way we would speed up the QuerySettings application on the hot path

       

      First we need to profile to check how much time is spent performing the linear scan and then decide whether or not it is worth utilizing more sophisticated data structures for faster set intersection

            Assignee:
            backlog-query-execution [DO NOT USE] Backlog - Query Execution
            Reporter:
            denis.grebennicov@mongodb.com Denis Grebennicov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: