When the $min query specifier is used without a corresponding $max, the upper index bound is the end of the index. This means that a query which uses $min but not $max may potentially scan from the lower bound all the way to the end of the index. This may be a considerable performance impact, compared to an equivalent query which lacks $min. This behaviour, and the corresponding recommendation to always use $min and $max together, should be noted on the following pages:
- http://docs.mongodb.org/manual/reference/operator/meta/min/
- http://docs.mongodb.org/manual/reference/method/cursor.min/
Similarly when $max is used without $min - the lower bound is the start of the index, and the query may scan from the start of the index up to the upper bound. This again may be much less performant than an equivalent query without $max. This behaviour, and the corresponding recommendation to always use $min and $max together, should be noted on the following pages:
- is related to
-
SERVER-17580 Warn when using only one of $min or $max index bounds
- Open
- related to
-
SERVER-15168 Allow intersection of $min/$max bounds with computed query indexBounds
- Closed