[SERVER-39241] Plan scoring incorrectly applies noFetchBonus bonus to all plans when no projection is provided Created: 29/Jan/19 Updated: 29/Oct/23 Resolved: 19/Nov/19 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 4.2.6, 4.3.2, 4.0.19 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Chris Harris | Assignee: | David Percy |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | query-44-grooming | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||||||||||
| Operating System: | ALL | ||||||||||||||||
| Backport Requested: |
v4.2, v4.0
|
||||||||||||||||
| Steps To Reproduce: |
Then check the log file |
||||||||||||||||
| Sprint: | Query 2019-11-18, Query 2019-12-02 | ||||||||||||||||
| Participants: | |||||||||||||||||
| Case: | (copied to CRM) | ||||||||||||||||
| Linked BF Score: | 0 | ||||||||||||||||
| Description |
|
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})
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:
|
| Comments |
| Comment by Githook User [ 22/Apr/20 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Author: {'name': 'David Percy', 'email': 'david.percy@mongodb.com', 'username': 'dpercy'}Message: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Githook User [ 31/Mar/20 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Author: {'name': 'David Percy', 'email': 'david.percy@mongodb.com', 'username': 'dpercy'}Message: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Githook User [ 19/Nov/19 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Author: {'username': 'dpercy', 'email': 'david.percy@mongodb.com', 'name': 'David Percy'}Message: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by David Storch [ 11/Apr/19 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I'm flagging this issue to be re-triaged, since james.wahlin identified a situation in which it is not benign. Quoting his comment from
I produced a short repro script which demonstrates the issue:
This script produces explain output such as the following:
Here we see that there is a rejected plan which is covered while the winning plan requires a FETCH in order to gather the fields required by the SHARDING_FILTER stage. This problem would be fixed by correcting the logic around noFetchBonus. It should be safe to award the noFetchBonus to any plan that has neither a FETCH or a COLLSCAN stage. |