Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-16286

explain.executionStats.nReturned should be docs returned by the winning plan

    XMLWordPrintableJSON

Details

    • 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. 

      Attachments

        Activity

          People

            matt.maville@mongodb.com Matthew Maville
            adi.agrawal@mongodb.com Adi Agrawal
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              27 weeks, 2 days ago