|
So I think for a real basic implementation we could do this:
- add all exact matches in query to beginning of the "best" index
- if we have a sort, then add the sort fields, we're done
- if no sort, add $in fields
- then we're left with ranges - do a table scan to see which range would result in the fewest nscanned, given constraints already present earlier in the index. We could yield during the scan - data consistency doesn't matter for this
Wouldn't handle various things like compound key ranges, but I think this would be a decent starting point for helping people out.
|