davisp commented on a change in pull request #469: Choose index based on fields 
match
URL: https://github.com/apache/couchdb/pull/469#discussion_r113814532
 
 

 ##########
 File path: src/mango/src/mango_cursor_view.erl
 ##########
 @@ -107,10 +107,14 @@ execute(#cursor{db = Db, index = Idx} = Cursor0, 
UserFun, UserAcc) ->
 % check FieldRanges for a, b, c, and d and return
 % the longest prefix of columns found.
 composite_indexes(Indexes, FieldRanges) ->
+    FieldKeys = [Key || {Key, _} <- FieldRanges],
     lists:foldl(fun(Idx, Acc) ->
         Cols = mango_idx:columns(Idx),
         Prefix = composite_prefix(Cols, FieldRanges),
-        [{Idx, Prefix} | Acc]
+        % create a KeysPrefixLength based on how close the prefix of
+        % the index is to the number of keys in the selector
+        KeysPrefixLength = length(FieldKeys) - length(Prefix),
 
 Review comment:
   I'm not following the logic on subtracting the prefix from the total length. 
At least, the name seems to be misleading. Shouldn't it be something like 
"ColumnsAfterPrefix"?
 
----------------------------------------------------------------
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

Reply via email to