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

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

    XMLWordPrintable

Details

    • Bug
    • Status: Open
    • Major - P3
    • Resolution: Unresolved
    • 1.25.0
    • None
    • Collection, CRUD, Query
    • None
    • 3

    Description

      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.

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated: