Priority: Major - P3
Affects Version/s: None
Fix Version/s: Backlog
Sprint:QE 2021-08-23, QE 2021-10-18, QE 2021-11-01, QE 2021-11-15, QE 2021-11-29, QE 2021-12-13
We have observed two performance improvements for set related expression:
- Use unordered sets instead of ordered sets
- Cache constant sets to avoid the set building
These two optimizations have been implemented for $setIsSubset expression, but not for other expressions.
One problem for porting these optimization to other set expression is using unordered sets causes the set element order being non deterministic. These can fail the fuzzer tests also may result in cascading non-deterministic expression values. (e.g. $group on $setIntersection). Note that this is not a problem for $setIsSubset expression since it's of boolean value. See related tickets https://jira.mongodb.org/browse/SERVER-58875 and https://jira.mongodb.org/browse/TIG-3254 for some context.
We have the following potential proposals:
- Sort the set expression values before return to ensure a consistent order
- Let the expression be non-deterministic, fix the fuzzer by either not generating set expressions or by other more complicated mechanisms.