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

Poor performance when using Views in Compass

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 1.18.0
    • Affects Version/s: None
    • Component/s: Compass
    • None
    • Iteration Unagi

      A user is reporting a timeout problem in Compass when clicking on a View where the underlying collection has around 15.2m documents and a total size of 517.2GB. Document's average size is 35.6KB.

      I have been able to reproduce the same problem in my testing environment.

      The problem only appears when the original collection is fairly large, (in my testing I could only generate the problem when I had 5M documents in it) and the View is not using a $match stage to filter out the content.

      Compass produce a timeout visible in the UI (see attachment)

      connection 0 to localhost:27018 timed out
      

      When the view is clicked in the UI, an aggregation pipeline is used to count the number of documents on the underlying collections. When the time to run this count command goes above a threshold that appears to be around 6 minutes, Compass timeout the operation.

      The following count operation is visible in the log:

      2018-11-20T08:28:35.583+1100 D COMMAND  [conn74] run command test.$cmd { count: "v_rides", query: {} }
      2018-11-20T08:28:35.583+1100 D COMMAND  [conn70] run command test.$cmd { count: "v_rides", query: {}, skip: 0 }
      2018-11-20T08:35:16.744+1100 I COMMAND  [conn70] command test.v_rides appName: "MongoDB Compass" command: count { count: "v_rides", query: {}, skip: 0 } planSummary: COLLSCAN keysExamined:0 docsExamined:5034881 cursorExhausted:1 numYields:39795 nreturned:1 reslen:40 locks:{ Global: { acquireCount: { r: 80268 } }, Database: { acquireCount: { r: 40134 } }, Collection: { acquireCount: { r: 40133 } } } protocol:op_query 401149ms
      2018-11-20T08:35:16.754+1100 I COMMAND  [conn74] command test.v_rides command: count { count: "v_rides", query: {} } planSummary: COLLSCAN keysExamined:0 docsExamined:5034881 cursorExhausted:1 numYields:39778 nreturned:1 reslen:40 locks:{ Global: { acquireCount: { r: 80234 } }, Database: { acquireCount: { r: 40117 } }, Collection: { acquireCount: { r: 40116 } } } protocol:op_query 401160ms
      

      I believe this is an undesirable behaviour because:
      1. If I click on the underlying collection documents are showed immediatelly
      2. If the timeout is caused by the count operation taking too long, this could be improved.
      3. Compass should be able to detect that a view is used and adapt its logic

            Assignee:
            durran.jordan@mongodb.com Durran Jordan
            Reporter:
            ivan.grigolon@mongodb.com Ivan Grigolon
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: