-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
-
Query Optimization
-
Fully Compatible
-
ALL
-
QO 2025-02-03
> db.adminCommand({setParameter:1, planRankerMode: "heuristicCE"}) > db.c.find({}, {a: {$meta: 'sortKey'}}).sort({a: 1}) MongoServerError: Encountered 34 stage in CardinalityEstimator which should be unreachable
The plan for this query looks like
winningPlan: { isCached: false, stage: 'PROJECTION_DEFAULT', transformBy: { a: { '$meta': 'sortKey' } }, inputStage: { stage: 'SORT_KEY_GENERATOR', inputStage: { stage: 'FETCH', inputStage: { stage: 'IXSCAN', keyPattern: { a: 1 }, indexName: 'a_1', isMultiKey: true, multiKeyPaths: { a: [ 'a' ] }, isUnique: false, isSparse: false, isPartial: false, indexVersion: 2, direction: 'forward', indexBounds: { a: [ '[MinKey, MaxKey]' ] } } } } },
CBR needs to fallback to multiplanning for plans which contain a SORT_KEY_GENERATOR stage.