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

how to using cover index for mongo count

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Done
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Operating System:
      ALL

      Description

      hi:

        count collecitons record including read metadata and scan documents.

      read metadata is fast but exists problem. and not suggest.

      scan documents is good but slow.

      db.collection.aggregate([\{$project:{_id:0}},\{$group:{_id:null,total:{$sum:1}}}])

      but is collscan.is there using cover index ?

       

      from document:it can use cover index:

      Changed in version 3.2: Starting in MongoDB 3.2, indexes can cover an aggregation pipeline. In MongoDB 2.6 and 3.0, indexes could not cover an aggregation pipeline since even when the pipeline uses an index, aggregation still requires access to the actual documents.

      is there example for me?

       

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            601290552@qq.com jing xu
            Participants:
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: