Details
-
Task
-
Resolution: Fixed
-
Major - P3
-
None
-
None
-
None
Description
Documentation Request Summary:
This commit adds a new option to the $collStats aggregation stage, allowing the user to get a 'fast count' for the number of records in the given collection. The count value must be an Object.
A more detailed description is located in the design document:
https://docs.google.com/document/d/1kHIQLLZv7ZMlW9aktZ6CIQdC1L8j3_PJxBdUx_q3FcQ/edit#heading=h.wybafdaad3h
Engineering Ticket Description:
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.
Attachments
Issue Links
- documents
-
SERVER-29620 Add shorthand syntax for retrieving the record count for a collection using the $collStats agg stage
-
- Closed
-