[SERVER-22743] Provide fast (estimated) count command Created: 18/Feb/16  Updated: 14/Jun/17  Resolved: 14/Jun/17

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

Type: Improvement Priority: Major - P3
Reporter: Osmar Olivo Assignee: David Storch
Resolution: Won't Fix Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on SERVER-7944 add index hint support for operations... Closed
Related
is related to SERVER-22093 Take advantage of the COUNT_SCAN opti... Closed
is related to SERVER-29620 Add shorthand syntax for retrieving t... Closed
Sprint: Query 2017-05-08
Participants:

 Description   

Today, depending on the context used, when .count() is used it will either do an expensive count operation to ensure accurate results, or it will invoke a data structure through a routine called fastCount that provides a rough estimate of the number of documents in a collection/database.

This can be confusing to users who expect the count operation to be an accurate precise count every time.

We should deprecate count command and add a countEstimate command. countEstimate will be O(1) though inaccurate and whenever users require an accurate count they should use the aggregation framework's facility for counting. The name countEstimate should be used in the stats data as well for clarity.



 Comments   
Comment by David Storch [ 14/Jun/17 ]

We are no longer planning to add a countEstimate command, so I am closing this ticket as "Won't Fix". Instead, we plan to implement SERVER-29620, which will make it easy to perform a fast estimated count using the aggregation framework. The syntax for retrieving the count will use the $collStats stage, which helps to clearly separate counting via query execution from counting by retrieving the approximate record count metadata. Count command will continue to conditionally use these "fast" and "slow" paths depending on the presence of a predicate, but the aggregation command will separately implement the fast and slow paths via $collStats and $count respectively.

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