Details
-
Task
-
Resolution: Unresolved
-
Major - P3
-
None
-
None
-
None
-
Query Optimization
-
QO 2024-02-05, QO 2024-02-19
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.