You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by "Garren Smith (JIRA)" <ji...@apache.org> on 2017/04/04 15:14:41 UTC

[jira] [Created] (COUCHDB-3357) Improve the way the index is chosen

Garren Smith created COUCHDB-3357:
-------------------------------------

             Summary: Improve the way the index is chosen
                 Key: COUCHDB-3357
                 URL: https://issues.apache.org/jira/browse/COUCHDB-3357
             Project: CouchDB
          Issue Type: Improvement
          Components: Mango
            Reporter: Garren Smith


Currently if two or more indexes are able to be used for a query the choose_best_index can get in a position where it will chose the index based based on sort order of its dbname, ddocid. This isn't ideal. 

If we have two docs like this:

doc1 = {
   name: "Mary"
};

doc2 = {
   name: "Mary",
   role: "Ceo"
};

If we create two indexes:
Index 1 = fields: ['name', 'role']
Index 2 = fields: ['name']

And if we create a query like this:

selector: {
   name: 'Mary'
};

If index 1 has a ddocId higher in the alphabet e.g A and Index 2 has a lower ddocId like Z. Then Index will be selected which means that doc 1 will be excluded. 

An example of a test case can be found here
https://github.com/apache/couchdb/blob/7951c8ae498e372d0db19887c6e39a91885df4e1/src/mango/test/12-use-correct-index.py



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)