diff options
author | Gabor Pali <gabor.pali@ibm.com> | 2023-02-14 12:46:28 +0100 |
---|---|---|
committer | Nick Vatamaniuc <nickva@users.noreply.github.com> | 2023-02-14 10:14:33 -0500 |
commit | 3fa8f72ac113dff073c9a764ba9189abb29ecba7 (patch) | |
tree | a18a19b2f5deeae6006a272df6c8e29e52e6f6a0 | |
parent | a650b446148f7f8913a0941fa9f80d2c441554ad (diff) | |
download | couchdb-3fa8f72ac113dff073c9a764ba9189abb29ecba7.tar.gz |
mango: Match comments with implementation for JSON index selection
-rw-r--r-- | src/mango/src/mango_cursor_view.erl | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/mango/src/mango_cursor_view.erl b/src/mango/src/mango_cursor_view.erl index c494e3d78..a784cf6b0 100644 --- a/src/mango/src/mango_cursor_view.erl +++ b/src/mango/src/mango_cursor_view.erl @@ -225,7 +225,7 @@ composite_prefix([Col | Rest], Ranges) -> % Prefix and the FieldRanges. If that is equal, then % choose the index with the least number of % fields in the index. If we still cannot break the tie, -% then choose alphabetically based on ddocId. +% then choose alphabetically based on (dbname, ddocid, view_name). % Return the first element's Index and IndexRanges. % % In the future we can look into doing a cached parallel @@ -247,9 +247,12 @@ choose_best_index(IndexRanges) -> M when M < 0 -> true; M when M == 0 -> - % We have no other way to choose, so at this point - % select the index based on (dbname, ddocid, view_name) triple - IdxA =< IdxB; + % Restrict the comparison to the (dbname, ddocid, view_name) + % triple -- in case of their equivalence, the original order + % will be maintained. + #idx{dbname = DbNameA, ddoc = DDocA, name = NameA} = IdxA, + #idx{dbname = DbNameB, ddoc = DDocB, name = NameB} = IdxB, + {DbNameA, DDocA, NameA} =< {DbNameB, DDocB, NameB}; _ -> false end; |