-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
-
Fully Compatible
-
ALL
-
Query Optimization 2021-03-22
-
(copied to CRM)
Before changing the index format, it is only possible to cover null queries in certain conditions:
- the index being scanned is not multikey, because indexes alone cannot distinguish between null, missing, undefined, and empty array values
- the query is either not projecting (as in the case of either legacy or aggregation count) or the query is projecting directly only onto the _id field. This is possible because _id fields are guaranteed to be unique and present, so we can have at most one _id field set to null in the index (meaning we would always get the right value for _id from the index).
Furthermore, we can optimize counts to use two COUNT_SCANs joined by an OR stage when a single null interval is encountered (instead of just using an INDEX_SCAN with a. filter).
This branched off of https://jira.mongodb.org/browse/SERVER-18861.
- is related to
-
SERVER-28889 Partial index shouldn't do fetch on conditions that are true by the definition of the index
- Closed
- related to
-
SERVER-12869 Index null values and missing values differently
- Backlog
-
SERVER-18861 Queries matching null value should be fully covered by index
- Backlog