[SERVER-56020] Unnecessary FETCH stage Created: 11/Apr/21 Updated: 25/Apr/21 Resolved: 20/Apr/21 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Index Maintenance, Performance, Query Execution |
| Affects Version/s: | 4.0.16 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Kay Agahd | Assignee: | Edwin Zhou |
| Resolution: | Duplicate | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||||||||||||||||||||||||||||
| Operating System: | ALL | ||||||||||||||||||||||||||||||||||||||||||
| Steps To Reproduce: | Here is a simplified example:
Here are the lines of the executionStats to show that the query was not covered because MongoDB fetched the whole document just to read the already known value of field del:
|
||||||||||||||||||||||||||||||||||||||||||
| Participants: | |||||||||||||||||||||||||||||||||||||||||||
| Description |
|
When using a partialFilterExpression with an $eq condition, MongoDB may fetch the document only to read the field of the $eq condition of the the partialFilterExpression. However, fetching the value should be superfluous because the value is already known by the partialFilterExpression. This is an undesired behaviour because it fetches uselessly documents from the disk which makes the query slow (especially, if documents are bigger). To circumvent the issue, you'd need to add the field of the $eq condition of the partialFilterExpression to the index. However, this makes the index bigger and as such it will uses more resources. |
| Comments |
| Comment by Kay Agahd [ 25/Apr/21 ] |
|
HiĀ edwin.zhou, |
| Comment by Edwin Zhou [ 20/Apr/21 ] |
|
Thank you for your detailed description of this behavior. I believe this issue duplicates Best, |