See BF-31072 for a detailed description/repro of the problem. The following pipeline (A) is ineligible for a COUNT_SCAN:
[{ $match: {"num": {$not: {$gt: NumberDecimal("9.999999999999999999999999999999999E+6144")}}} }, {$count: "num"}]
However, when this pipeline (B) runs first:
[{$match: {"num": {$not: {$gt: NumberDecimal("Infinity")}}}}, {$count: "num"}]
B uses a COUNT_SCAN, and generates a plan-cache entry, which A then (incorrectly) uses. Both queries should match/count an empty document {}; however, B does not count it when using a COUNT_SCAN.
This is only reproducible with SBE enabled, plan cache on, and match expression optimization enabled.
- is related to
-
SERVER-91001 SBE plan cache can pick wrong IndexScan plan
- Open