[SERVER-48935] how to using cover index for mongo count Created: 18/Jun/20  Updated: 18/Jun/20  Resolved: 18/Jun/20

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: jing xu Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Participants:

 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?

 



 Comments   
Comment by Carl Champain (Inactive) [ 18/Jun/20 ]

Hi 601290552@qq.com,

The SERVER project is for bugs and feature suggestions for the MongoDB server. As this ticket does not appear to be a bug, I will now close it. If you need further assistance troubleshooting, I encourage you to ask our community by posting on the MongoDB Community Forums or on Stack Overflow with the mongodb tag.

Kind regards,
Carl

 

Comment by jing xu [ 18/Jun/20 ]

using COLL_SCAN not using COUNT_SCAN.

Generated at Thu Feb 08 05:18:28 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.