[SERVER-80937] Avoid linear lookup for allowed indexes in applyQuerySettings() Created: 11/Sep/23  Updated: 12/Sep/23

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

Type: Task Priority: Major - P3
Reporter: Denis Grebennicov Assignee: Backlog - Query Execution
Resolution: Unresolved Votes: 0
Labels: M3
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to SERVER-80931 Cache QuerySettings hash, such that i... Backlog
is related to SERVER-79181 Apply QuerySettings for find commands Closed
Assigned Teams:
Query Execution
Participants:

 Description   

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


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