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

Allow COUNT stage to sum COUNT_SCANS for queries with $in operator

    • Type: Icon: Improvement Improvement
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Querying
    • Labels:
      None
    • Query

      Count over covered index happens too slow if $in condition exists. Example:

      db.forum.topics.count({ "section": ObjectId("56b25ca88d4b465a5dda716e"), "st": { "$in": [ 1, 2] } })

      takes ~50ms with 20000 keys examined, while separate queries takes 1 & 0 ms:

      db.forum.topics.count({ "section": ObjectId("56b25ca88d4b465a5dda716e"), "st": 1 })

      db.forum.topics.count({ "section": ObjectId("56b25ca88d4b465a5dda716e"), "st": 2 })

      Not we split such $in queries to mutiple, but:

      1. That's not convenient
      2. That's impossible for "pagination" requests, when you have $in and skip+limit.

            Assignee:
            backlog-server-query Backlog - Query Team (Inactive)
            Reporter:
            vitaly Vitaly Puzrin
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: