-
Type:
Bug
-
Resolution: Unresolved
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
Query Optimization
-
ALL
-
-
None
-
None
-
None
-
None
-
None
-
None
-
None
countUniqueDocuments counts distinct _id values, but CBR samples that are projected without _id, result in the count of 1.
In SamplingEstimatorImpl::estimateNDV, a sample NDV of 1 combined with 1 unique document triggers the early return for unique fields, which returns the collection cardinality. This affects `estimateIndexSeeks` estimates.
Join samples are not projected today, so the join optimizer is not affected.
Proposed fix
Count distinct sampled documents by RecordId when the sample is generated on the fly, and by _id when a persisted sample is loaded (persisted samples are stored without projection).
- is depended on by
-
SERVER-136693 CBR index seek estimate is close to the collection size when few sample documents satisfy the leading bounds
-
- Needs Scheduling
-
- related to
-
SERVER-136561 Improve index seek estimation
-
- Backlog
-