Can MongoDB use an index when checking for existence of a field with $exists operator?


Seems $exists queries use index properly now based on these tickets
$exists queries should use index & {$exists: false} will not use index

Old Answer:

No, there is no way to tell mongodb to use index for exists query. Indexing is completely related to data. Since $exists is only related to the keys (fields) it cant be used in indexes.

$exists just verifies whether the given key (or field) exists in the document.

Leave a Comment