willholley commented on issue #863: Fix exists false when field is explicitly 
defined
URL: https://github.com/apache/couchdb/pull/863#issuecomment-334692468
 
 
   @tonysun83 if a user specifies `{"$exists": false}` explicitly, we can never 
use an index to fulfil that predicate (you're correct that this was addressed 
in 
https://github.com/apache/couchdb/commit/503f3e34afa0a68e91258ca864e70ab18e6584e2).
 Can you provide an example where you think we'll trip up (or ideally, a 
failing test)?
   
   As a general rule, I think we should consider it a bug whenever there is 
variation in results due to indexes being present, the exception being 
index-specific operators such as `$text`. The expectation is that a user will 
start with no indexes (so queries will default to _all_docs) and add indexes 
when necessary to improve performance or when sorting is required. Adding an 
index to an existing application should never change the results of queries 
already being used.
   
   Another thing to note, for awareness, is that an explicit [partial 
index](https://github.com/apache/couchdb/pull/808) could be used to optimise an 
`{"$exists": false}` selector but these require users to opt-in - the query 
planner will never automatically select them.
 
----------------------------------------------------------------
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