Uploaded image for project: 'Compass '
  1. Compass
  2. COMPASS-4587

The initial document count (with empty filter) is very slow

    • Type: Icon: Bug Bug
    • Resolution: Gone away
    • Priority: Icon: Major - P3 Major - P3
    • No version
    • Affects Version/s: 1.25.0
    • Component/s: Collection, CRUD, Query
    • None
    • 3
    • Not Needed

      The initial document count is very slow since the server seems to be scanning the whole collection.

      To reproduce: try to load a big collection, the first load will take seconds. Moving to next page afterwards (which does not involve re-counting) is almost instantaneous.

      I'd expect the first page load to be as fast as the next page since the same amount of documents are loaded.

      Possible fixes:

      • Make the count independent from the find and only report the result in the ui when is ready.
      • Use the id field as hint if query is empty: countDocuments({}, {hint: '_id_'}

        ). For what i could test this speeds up the count a tons, the server seems to do an index scan in this case.

            Assignee:
            Unassigned Unassigned
            Reporter:
            maurizio.casimirri@mongodb.com Maurizio Casimirri
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: