We currently don't have any tests for plan ranking. Such tests would specify the indices, data, and query, and then show that ranking chooses the right plan.
Some interesting cases include, but are not limited to:
- Two plans hit EOF at the same time, but one is covered. Make sure that we prefer the covered plan.
- A query where using an index requires us to look at the entire collection. In this case, a collection scan will hit EOF first and should win.
- No plan produces any results or hits EOF. In this case we should never choose an index intersection solution.
- No plan produces any results or hits EOF. In this case we should prefer covered solutions to non-covered solutions.
- We have an index on "a" which is somewhat selective and an index on "b" which is highly selective (will cause an immediate EOF). Make sure that a query with predicates on both "a" and "b" will use the index on "b".