The 3.1.1 version of partial indexes decides if a given query is compatible with a given partial index by checking if the query's root predicate describes a subset of the documents that the partial index document filter describes. However, this does not allow $or predicates to be indexed by partial indexes, as $or predicates are indexed by a union of scans on separate indexes.
This would allow the following query to be answerable by a union of scans on the following two indexes:
- query: find({$or: [{a: 1, f: true}, {b: 1}]})
- index #1: key pattern {a: 1}, partial index document filter {f: true}
- index #2: key pattern {b: 1}
- is duplicated by
-
SERVER-18092 Convert index_partial2.js test to query planner unit tests.
-
- Closed
-
- related to
-
SERVER-19511 Distinct command with no predicate can miss results when distinct field is first key pattern element of partial index
-
- Closed
-
-
SERVER-104089 Inefficient Index Scans for $or Queries Using Partial Indices
-
- Needs Verification
-