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

how to using cover index for mongo count

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • ALL

      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?

       

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

              Created:
              Updated:
              Resolved: