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

result of collection count function does not equals with result of aggregate count function

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • None
    • None
    • Querying
    • None
    • ALL
    • Hide

      db.collection.count() shows 5
      but aggregate count as below shows 6

      db.runCommand(
        {
            aggregate:"collection", 
            pipeline:[
                   {
                       $group:{ _id:null, count: {$sum:1} }
                   }
            ] 
         }
      )
      

      Show
      db.collection.count() shows 5 but aggregate count as below shows 6 db.runCommand( { aggregate:"collection", pipeline:[ { $group:{ _id:null, count: {$sum:1} } } ] } )

    Description

      evn description:
      standalone database.
      6 document data exists in collection.

      but we got two different results via pure count function and aggregate count function according to below docs.
      https://docs.mongodb.com/manual/reference/command/count/#dbcmd.count

      I'm not sure whether this is a bug or my command is wrong.

      Attachments

        Activity

          People

            kelsey.schubert@mongodb.com Kelsey Schubert
            8666592@qq.com jacky chen
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: