Uploaded image for project: 'Drivers'
  1. Drivers
  2. DRIVERS-501

Implement new count API

    • Type: Icon: New Feature New Feature
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Component/s: None
    • Labels:
      None
    • $i18n.getText("admin.common.words.hide")
      Key Status/Resolution FixVersion
      PYTHON-1580 Fixed 3.7
      NODE-1501 Fixed 3.1.0
      SCALA-422 Fixed 2.4.0
      CSHARP-2293 Fixed 2.7.0
      PERL-926 Fixed 2.0.0
      RUBY-1354 Fixed 2.6.0
      JAVA-2885 Fixed 3.8.0
      CXX-1594 Fixed 3.4.0
      PHPLIB-354 Fixed 1.4.0
      MOTOR-241 Fixed 2.0
      GODRIVER-453 Done 0.0.11
      CDRIVER-2691 Fixed 1.11.0
      RUST-65 Fixed 0.9.0-alpha
      SWIFT-419 Duplicate
      $i18n.getText("admin.common.words.show")
      #scriptField, #scriptField *{ border: 1px solid black; } #scriptField{ border-collapse: collapse; } #scriptField td { text-align: center; /* Center-align text in table cells */ } #scriptField td.key { text-align: left; /* Left-align text in the Key column */ } #scriptField a { text-decoration: none; /* Remove underlines from links */ border: none; /* Remove border from links */ } /* Add green background color to cells with FixVersion */ #scriptField td.hasFixVersion { background-color: #00FF00; /* Green color code */ } /* Center-align the first row headers */ #scriptField th { text-align: center; } Key Status/Resolution FixVersion PYTHON-1580 Fixed 3.7 NODE-1501 Fixed 3.1.0 SCALA-422 Fixed 2.4.0 CSHARP-2293 Fixed 2.7.0 PERL-926 Fixed 2.0.0 RUBY-1354 Fixed 2.6.0 JAVA-2885 Fixed 3.8.0 CXX-1594 Fixed 3.4.0 PHPLIB-354 Fixed 1.4.0 MOTOR-241 Fixed 2.0 GODRIVER-453 Done 0.0.11 CDRIVER-2691 Fixed 1.11.0 RUST-65 Fixed 0.9.0-alpha SWIFT-419 Duplicate

      Drivers supporting MongoDB 4.0 must deprecate the count() helper and add two new helpers - estimatedDocumentCount() and countDocuments(). Both helpers are supported with MongoDB 2.6+.

      The names of the new helpers were chosen to make it clear how they behave and exactly what they do. The estimatedDocumentCount helper returns an estimate of the count of documents in the collection using collection metadata, rather than counting the documents or consulting an index. The countDocuments helper counts the documents that match the provided query filter using an aggregation pipeline.

      The count() helper is deprecated. It has always been implemented using the count command. The behavior of the count command differs depending on the options passed to it and the topology in use and may or may not provide an accurate count. When no query filter is provided the count command provides an estimate using collection metadata. Even when provided with a query filter the count command can return inaccurate results with a sharded cluster if orphaned documents exist or if a chunk migration is in progress. The countDocuments helper avoids these sharded cluster problems entirely when used with MongoDB 3.6+, and when using `Primary` read preference with older sharded clusters.

      The following spec change describes the necessary changes in detail, including implementation notes and yml / json spec tests:

      https://github.com/mongodb/specifications/commit/99ef4e71c68811912da49b451408764eba73015c

      The reference implementation for this change is provided by the Python driver and is in code review now.

            Assignee:
            rathi.gnanasekaran Rathi Gnanasekaran
            Reporter:
            bernie@mongodb.com Bernie Hackett
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: