-
Type:
Bug
-
Resolution: Unresolved
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
Query Optimization
-
ALL
-
-
None
-
3
-
None
-
None
-
None
-
None
-
None
-
None
IF we have a hashed index on a, a cost estimate on b is incorrect, even though the cardinality estimate is correct.
Right now any plans involving a hashed index will not be put through the CBR, so the fact that the cost estimate is incorrect does not seem to matter.
Enterprise test> db.foo.find({a:1,b:1}).explain().queryPlanner.rejectedPlans[0].inputStage; { stage: 'AND_SORTED', inputStages: [ { stage: 'IXSCAN', costEstimate: 1.7976931348623157e+308, <- HERE cardinalityEstimate: 1, numKeysEstimate: 1, estimatesMetadata: { ceSource: 'Histogram' }, keyPattern: { b: 1 }, indexName: 'b_1', isMultiKey: false, multiKeyPaths: { b: [] }, isUnique: false, isSparse: false, isPartial: false, indexVersion: 2, direction: 'forward', indexBounds: { b: [ '[1, 1]' ] } }, { stage: 'IXSCAN', keyPattern: { a: 'hashed' }, indexName: 'a_hashed', isMultiKey: false, isUnique: false, isSparse: false, isPartial: false, indexVersion: 2, direction: 'forward', indexBounds: { a: [ '[5902408780260971510, 5902408780260971510]' ] } } ] }
Compare with the estimate for the same index and interval if it is in a stand-alone IXSCAN:
inputStage: { stage: 'IXSCAN', costEstimate: 0.0144587,<- THIS VALUE IS MORE REASONABLE cardinalityEstimate: 1, numKeysEstimate: 1, estimatesMetadata: { ceSource: 'Histogram' }, keyPattern: { b: 1 }, indexName: 'b_1', isMultiKey: false, multiKeyPaths: { b: [] }, isUnique: false, isSparse: false, isPartial: false, indexVersion: 2, direction: 'forward', indexBounds: { b: [ '[1, 1]' ] } } },