In situation where there are two plans that tie, if one matches more (leading?) keys in the query than another then it's more likely to be a better plan for other queries of this shape.
Example:
db.collection.find({a:999, b:111, c:"x"}).sort({d:-1}) // indexes for collection: {a:1,b:1,c:1,d:1} {a:1,b:1,d:1} {a:1,d:1}
For value of a in query that matches one or no documents all three indexes are going to perform equally (yes?) - we should break the tie in favor of the first one because it matches the most predicate fields in the query.
- duplicates
-
SERVER-80233 Implement index prefix heuristic
- Closed
- is duplicated by
-
SERVER-59337 Bad index selection when using $in
- Closed
-
SERVER-40844 Better tie breaking of "perfect" indexes
- Closed
- is fixed by
-
SERVER-80233 Implement index prefix heuristic
- Closed
- related to
-
SERVER-13211 Optimal index not chosen for query plan when many indexes match same prefix
- Closed