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

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

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Duplicate
    • Icon: Major - P3 Major - P3
    • None
    • None
    • Querying
    • None
    • Query

    Description

      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.

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: