willholley opened a new pull request #1069: Mango: change catch-all field range priority URL: https://github.com/apache/couchdb/pull/1069 ## Overview 01252f97 introduced a "catch-all" feature to Mango that allowed queries to fall back on a full database scan (_all_docs) when no valid index was available. This worked by creating a special index range representing the full database scan. For example, a selector: `{ "_id": "foo" }` would be translated into a field range of: `[{ "startkey": "foo", "endkey": "foo"}]` then prepending the catch-all field range, we would have: ``` [ { "startkey": null, "endkey": max_json_value}, { "startkey": "foo", "endkey": "foo"} ] ``` This set gets passed into mango_cursor_view:choose_best_index to determine most selective index and field range combination to use. Unfortunately, in the event that we have one possible index (all_docs) and multiple valid ranges, it just chooses the first range it finds - the full index scan in this case. This commit makes the catch-all field range the last available option, ensuring we use the more selective range where available. ## Testing recommendations Run queries against a large database with no indexes. Check execution_stats and _explain output to see that the startkey and endkey used are appropriate. ## Related Issues or Pull Requests <!-- If your changes affects multiple components in different repositories please put links to those issues or pull requests here. --> ## Checklist - [ ] Code is written and works correctly; - [ ] Changes are covered by tests; - [ ] Documentation reflects the changes;
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
