-
Type: Improvement
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: Aggregation Framework, Querying
-
None
-
Fully Compatible
-
Query 2017-06-19
-
0
The number of documents in a collection can already be retrieved using $collStats in O(1) time—that is, without executing a query to count the total number of documents. However, we would like to provide syntactic sugar in order to make this easy. Specifically, we will add a count option to $collStats:
> db.myColl.aggregate([{$collStats: {count: {}}}]); { ns: "test.myColl", localTime: ISODate("2017-06-02T15:48:46.510Z"), count: 11 }
This aggregation will return a single document with the ns and localTime fields, just like other $collStats pipelines. The count will be reported in a new field called count.
- related to
-
SERVER-22743 Provide fast (estimated) count command
- Closed