willholley closed pull request #1069: Mango: change catch-all field range
priority
URL: https://github.com/apache/couchdb/pull/1069
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/src/mango/src/mango_cursor_special.erl
b/src/mango/src/mango_cursor_special.erl
index 78cac7f5d5..f4a760d1c3 100644
--- a/src/mango/src/mango_cursor_special.erl
+++ b/src/mango/src/mango_cursor_special.erl
@@ -31,10 +31,13 @@
create(Db, Indexes, Selector, Opts) ->
InitialRange = mango_idx_view:field_ranges(Selector),
CatchAll = [{<<"_id">>, {'$gt', null, '$lt', mango_json_max}}],
- FieldRanges = lists:append(CatchAll, InitialRange),
+ % order matters here - we only want to use the catchall index
+ % if no other range can fulfill the query (because we know)
+ % catchall is the most expensive range
+ FieldRanges = InitialRange ++ CatchAll,
Composited = mango_cursor_view:composite_indexes(Indexes, FieldRanges),
{Index, IndexRanges} = mango_cursor_view:choose_best_index(Db, Composited),
-
+
Limit = couch_util:get_value(limit, Opts, mango_opts:default_limit()),
Skip = couch_util:get_value(skip, Opts, 0),
Fields = couch_util:get_value(fields, Opts, all_fields),
diff --git a/src/mango/test/03-operator-test.py
b/src/mango/test/03-operator-test.py
index 239cc7d416..4650c7e84e 100644
--- a/src/mango/test/03-operator-test.py
+++ b/src/mango/test/03-operator-test.py
@@ -264,6 +264,13 @@ class OperatorTextTests(mango.UserDocsTextTests,
OperatorTests):
class OperatorAllDocsTests(mango.UserDocsTestsNoIndexes, OperatorTests):
- pass
+ def test_range_id_eq(self):
+ doc_id = "8e1c90c0-ac18-4832-8081-40d14325bde0"
+ r = self.db.find({
+ "_id": doc_id
+ }, explain=True, return_raw=True)
+
+ self.assertEqual(r["mrargs"]["end_key"], doc_id)
+ self.assertEqual(r["mrargs"]["start_key"], doc_id)
----------------------------------------------------------------
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