<!-- llms-explorer concept facts · https://llms-explorer.com/tree/exists-query-bounds-on-indexes/ · pack 2026-10-21 · ~743 tokens -->

# $exists query bounds on indexes

> Source-anchored research for $exists query bounds on indexes. Run status: COMPLETED.

Parent: [MongoDB Compound Index Design: ESR, Selectivity, Covering and Multikey Bounds](https://llms-explorer.com/tree/mongodb-compound-index-design-esr-selectivity-covering-and-multikey-bounds/) · 4 facets · 6 facts · page: https://llms-explorer.com/tree/exists-query-bounds-on-indexes/

## Structure and components

- An all-ascending/descending compound sparse index includes a document when at least one indexed key has a value. Index membership therefore does not by itself prove that every individual component exists; the exact sparse-index claim above is limited to a single-field index. (low confidence) (verified as of 2026-10-14) — [source](https://www.mongodb.com/docs/manual/core/index-sparse.md)

## How it works

- $exists:true matches documents where the field is present, including an explicit null value; $exists:false matches only documents where the field is absent. A null equality query is different because it also matches missing fields. (high confidence) (verified as of 2026-10-21) — [source](https://www.mongodb.com/docs/manual/reference/operator/query/exists/)

## Problems, failure modes and limitations

- A sparse index on f cannot answer {f: {$exists: false}} because it omits the matching missing-field documents, so MongoDB requires a COLLSCAN for that index. A non-sparse index can scan the null-key candidates and use FETCH to distinguish absent fields from explicitly-null fields; the optimizer may still prefer a collection scan. (medium confidence) (verified as of 2026-10-18) — [source](https://www.mongodb.com/docs/manual/reference/operator/query/exists/)
- A partial index filtered by {f: {$exists: true}} only covers documents where f exists. MongoDB uses a partial index only when the query implies its filter, so that index cannot answer {f: {$exists: false}} without omitting matches. (medium confidence) (verified as of 2026-10-14) — [source](https://www.mongodb.com/docs/manual/core/index-partial.md)

## Facts and statements

- For a single-field sparse index on f, {f: {$exists: true}} can use the full [MinKey, MaxKey] range as an exact existence test: missing fields have no index entries, but explicit null values do. MongoDB does not need a FETCH just to recheck existence, though it may fetch documents to return fields that are not covered by the index. (high confidence) (verified as of 2026-10-18) — [source](https://www.mongodb.com/docs/manual/reference/operator/query/exists/)
- A non-sparse single-field index stores a null-like key for documents missing f. Therefore, {f: {$exists: true}} has no selective value bound from existence alone: an observed IXSCAN spans [MinKey, MaxKey] and FETCH applies the $exists filter, examining all index entries and documents. (high confidence) (verified as of 2026-10-18) — [source](https://www.mongodb.com/docs/manual/reference/operator/query/exists/)
