Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-40090

DISTINCT_SCAN in agg is only used when certain format of _id is specified

    XMLWordPrintable

    Details

      Description

      Implementation inĀ SERVER-9507 only works when specific format for _id in $group is used:

      // works
      db.newTest.explain(1).aggregate([
         {$sort:{valueDate:1}},
         {$group:{_id: "$valueDate", first: {$first: "$farmId"}}}
      ]).stages[0]["$cursor"]["executionStats"]
      {
              "executionSuccess" : true,
              "nReturned" : 2,
              "executionTimeMillis" : 0,
              "totalKeysExamined" : 2,
              "totalDocsExamined" : 2,
      ... }
      // doesn't work
      db.newTest.explain(1).aggregate([
        {$sort:{valueDate:1}},
        {$group:{_id: {v:"$valueDate"}, first: {$first: "$farmId"}}}
      ]).stages[0]["$cursor"]["executionStats"]
      {
              "executionSuccess" : true,
              "nReturned" : 5,
              "executionTimeMillis" : 0,
              "totalKeysExamined" : 10,
              "totalDocsExamined" : 5,
      ... }
       

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                7 Start watching this issue

                Dates

                • Created:
                  Updated: