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

Deferred query EstimatedDocumentCount helper incorrect with filter

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 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@mongodb.com Huan Li (Inactive)
            Reporter:
            david.golden@mongodb.com David Golden
            Evgeni Dobranov, Tim Fogarty
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: