-
Type: Task
-
Resolution: Done
-
Priority: Minor - P4
-
Affects Version/s: None
-
Labels:
This documentation page says:
-$in can be an equality operator or a range operator. --When $in is used alone, it is an equality operator that performs a series of equality matches. --When $in is used with .sort(), $in can act like a range operator.
A few people have found this confusing. To clarify: when $in is used with a sort(), there are two cases. For a small $in list (less than 200 elements) the $in can be "exploded" and treated as a bunch of point lookups in the index which are merged in the correct sort order.
For large $in lists (when a sort is present), this optimization is not possible, and the index cannot provide the sort. However, saying $in "acts" as a range predicate is a bit misleading, since it's still a bunch of equality predicates. What I would instead say is that from an ESR perspective, a large $in should be ordered like a range predicate, rather than an equality one. This is a very subtle distinction, but I think worth clarifying in the docs.