[DOCS-16286] explain.executionStats.nReturned should be docs returned by the winning plan Created: 31/Jul/23 Updated: 06/Feb/24 Resolved: 06/Feb/24 |
|
| Status: | Closed |
| Project: | Documentation |
| Component/s: | manual, Server |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Task | Priority: | Minor - P4 |
| Reporter: | Adi Agrawal | Assignee: | Matthew Maville |
| Resolution: | Done | Votes: | 0 |
| Labels: | backlog, query, quick-win, request | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||
| Participants: | |||||
| Days since reply: | 27 weeks, 2 days ago | ||||
| Story Points: | 2 | ||||
| Description |
|
Currently, explain.executionStats.nReturned reads: Number of documents that match the query condition. It should instead be the number of documents returned by the winning plan. This subtle difference can be seen in the following scenario: I have the following docs in my collection:[\{a: 1}, \{a: 2}, \{a: 3}] and run the agg pipeline [{$addFields: {"diff": {$subtract: [5, "$a"]}, {$match: {"diff": {$lte: 2}}}]{}}}, we return 1 doc. When running explain on this aggregate, the winning plan in the case of the classic engine is just COLLSCAN (without any filter) and nReturned is 3. |