summaryrefslogtreecommitdiff
path: root/src/mango/src/mango_cursor_special.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/mango/src/mango_cursor_special.erl')
-rw-r--r--src/mango/src/mango_cursor_special.erl7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/mango/src/mango_cursor_special.erl b/src/mango/src/mango_cursor_special.erl
index 78cac7f5d..f4a760d1c 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),