Hello,
I have a collection with document similar to { A, B, C(optional) }
I build an index: { A:1 B:1 }
My aim is to test the availability in base of document, as fast as possible so I need only to know if I have a doc, what ever is the content.
1. When I query with ...find( { A:a, B:b, C:{$exists : false }, {_id:0, A:1} ),
the explain() tells me that I am only hitting the index (btw this is what I want)
but I doesnt understand how it can only hit index without scanning the docs to know presence or not of this C field, or the "indexOnly" is setted to true because beginning of query start using index ?
2. About findOne() does it works exactly like a find().limit(1) (about the index hitting) ?
2 bis. What are performance between findOne() and .find().limit(1).count(true) ?
Best regards