Deferred query EstimatedDocumentCount helper incorrect with filter

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Major - P3
    • 100.3.0
    • Affects Version/s: None
    • Component/s: None
    • None

      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.

              Assignee:
              Huan Li (Inactive)
              Reporter:
              David Golden
              Evgeni Dobranov (Inactive), Tim Fogarty
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: