|
Due to SERVER-12869, normal indexes require a FETCH for exists:false and exists:true queries.
We have a section in our documentation on Using sparse indexes to improve exists performance
As SERVER-12869 has been open since 2014, would it make sense to expand the discussion of indexing exists to include the implications of that ticket:
We can safely use an index on $exists queries in the following cases:
|
{a:{ $exists:true }} - normal index helps, but we must still fetch
|
{a:{ $exists:true }} - sparse index is exact
|
{a:{ $exists:false }} - normal index requires a fetch
|
{a:{ $exists:false }} - never
|
Based on customer feedback, this was not clear from the documentation.
|