Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-23017

Fast approximate count with predicate

    • Type: Icon: New Feature New Feature
    • Resolution: Unresolved
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: Querying
    • None
    • Query Optimization

      I've indexed the queried fields, which makes the count works very fast when nobody is updating documents in the collection, but whenever i start more workers, or whenever there is some load, the output is very slow:

      2016-03-09T00:58:22.805+0200 I COMMAND  [conn2451] command squeue.in_auth command: count { count: "in_auth", query: { payload.group: "group1" } } planSummary: COUNT_SCAN { payload.group: 1.0, payload.customer: 1.0 } keyUpdates:0 writeConflicts:0 numYields:8125 reslen:122 locks:{ Global: { acquireCount: { r: 16252 } }, Database: { acquireCount: { r: 8126 } }, Collection: { acquireCount: { r: 8126 } } } protocol:op_query 511ms
      

      Is there any way to make an approximative, but FAST count which ignores the updates? It doesn't matter if it displays a few hundred more or less items in a collection with 10 million docs.

      I'm on a sharded cluster btw (8 rs).

            Assignee:
            backlog-query-optimization [DO NOT USE] Backlog - Query Optimization
            Reporter:
            thestick613 Tudor Aursulesei
            Votes:
            6 Vote for this issue
            Watchers:
            18 Start watching this issue

              Created:
              Updated: