Uploaded image for project: 'MongoDB Database Tools'
  1. MongoDB Database Tools
  2. TOOLS-2751

Deferred query EstimatedDocumentCount helper incorrect with filter

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • None
    • 100.3.0
    • None
    • None

    Description

      The tools-common type db.DeferredQuery has a method EstimatedDocumentCount, but estimated counts are only possible on full collections, not on queries with filters.

      As currently written, it will ignore the filter and return a full collection count, which is wrong.

      I suggest the following changes:

      • Run EstimatedDocumentCount on the underlying collection if the filter is nil or an empty BSON document
      • Run CountDocuments on the underlying collection otherwise
      • Consider renaming db.DeferredQuery.EstimatedDocumentCount to db.DeferredQuery.Count.

      Attachments

        Activity

          People

            huan.li@mongodb.com Huan Li
            david.golden@mongodb.com David Golden
            Evgeni Dobranov, Tim Fogarty
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: