[SERVER-83270] Avoid sorting $in list when it gets converted to KeyString Created: 15/Nov/23  Updated: 02/Feb/24

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

Type: Task Priority: Major - P3
Reporter: Ian Boros Assignee: Militsa Sotirova
Resolution: Unresolved Votes: 1
Labels: query-perf-q4
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Query Optimization
Sprint: QO 2024-02-05, QO 2024-02-19
Participants:

 Description   

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.


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