-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
Fully Compatible
-
ALL
-
v4.2, v4.0
-
-
Query 2019-11-18, Query 2019-12-02
-
(copied to CRM)
-
0
When a projection is applied to a query, the algorithm to score the plans correctly takes into consideration if a plan is covered or not. This can be seen in the following log output ("query" component set to level 2) for the operation find({x:123},{_id:0, y:1})
2019-01-28T21:58:09.666-0600 D QUERY [conn12] Scoring query plan: IXSCAN { x: 1 } planHitEOF=1 2019-01-28T21:58:09.666-0600 D QUERY [conn12] score(1.0002) = baseScore(1) + productivity((0 advanced)/(1 works) = 0) + tieBreakers(0 noFetchBonus + 0.0001 noSortBonus + 0.0001 noIxisectBonus = 0.0002) 2019-01-28T21:58:09.666-0600 D QUERY [conn12] Scoring query plan: IXSCAN { x: 1, y: 1 } planHitEOF=1 2019-01-28T21:58:09.666-0600 D QUERY [conn12] score(1.0003) = baseScore(1) + productivity((0 advanced)/(1 works) = 0) + tieBreakers(0.0001 noFetchBonus + 0.0001 noSortBonus + 0.0001 noIxisectBonus = 0.0003) 2019-01-28T21:58:09.667-0600 D QUERY [conn12] Winning plan: IXSCAN { x: 1, y: 1 }
As expected, only the plan using the {x:1,y:1} index received a nonzero noFetchBonus value.
However, when the command is issued without a projection (eg find({x:123})), both of the plans receive the bonus despite the fact that they both contain FETCH stages:
2019-01-28T22:00:04.415-0600 D QUERY [conn12] Scoring query plan: IXSCAN { x: 1 } planHitEOF=1 2019-01-28T22:00:04.415-0600 D QUERY [conn12] score(1.0003) = baseScore(1) + productivity((0 advanced)/(1 works) = 0) + tieBreakers(0.0001 noFetchBonus + 0.0001 noSortBonus + 0.0001 noIxisectBonus = 0.0003) 2019-01-28T22:00:04.415-0600 D QUERY [conn12] Scoring query plan: IXSCAN { x: 1, y: 1 } planHitEOF=1 2019-01-28T22:00:04.416-0600 D QUERY [conn12] score(1.0003) = baseScore(1) + productivity((0 advanced)/(1 works) = 0) + tieBreakers(0.0001 noFetchBonus + 0.0001 noSortBonus + 0.0001 noIxisectBonus = 0.0003) 2019-01-28T22:00:04.416-0600 D QUERY [conn12] Winning plan: IXSCAN { x: 1 }
- is related to
-
SERVER-39191 Performance regression for counts post-sharding
- Closed