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

XMLWordPrintableJSON

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

      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
              Reporter:
              Maurizio Casimirri
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: