Skip to content

Commit 0830ec5

Browse files
(DOCS-15142): Add inaccurate count warning for fcbis (#1189) (#1192)
* (DOCS-15142): Add inaccurate count warning for fcbis * update count method page * refactor count method page * formatting * add ref and link * update count method page * tweaks
1 parent 8c1006c commit 0830ec5

File tree

4 files changed

+77
-59
lines changed

4 files changed

+77
-59
lines changed

source/core/replica-set-sync.txt

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ based*.
4141
Logical Initial Sync Process
4242
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4343

44-
When you perform a
45-
:ref:`logical initial sync <replica-set-initial-sync-logical>`, MongoDB:
44+
When you perform a logical initial sync, MongoDB:
4645

4746
#. Clones all databases except the :ref:`local
4847
<replica-set-local-database>` database. To clone, the
@@ -72,15 +71,25 @@ To perform an initial sync, see
7271
File Copy Based Initial Sync
7372
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7473

75-
:ref:`File copy based initial sync
76-
<replica-set-initial-sync-file-copy-based>` runs the initial sync
77-
process by copying and moving files on the file system.
74+
File copy based initial sync runs the initial sync process by copying
75+
and moving files on the file system.
7876

7977
File copy based initial sync can be faster than
8078
:ref:`logical initial sync <replica-set-initial-sync-logical>`.
8179

8280
It is only available on Enterprise Server.
8381

82+
.. important:: File copy based initial sync may cause inaccurate counts
83+
84+
After file copy based initial sync completes, if you run the
85+
:method:`~db.collection.count()` method without a query predicate, the
86+
count of documents returned may be inaccurate.
87+
88+
A ``count`` method without a query predicate looks like this:
89+
``db.<collection>.count()``.
90+
91+
To learn more, see :ref:`count-method-behavior-query-predicate`.
92+
8493
Limitations
8594
```````````
8695

source/reference/command/count.txt

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -139,27 +139,29 @@ Definition
139139
- :method:`db.collection.estimatedDocumentCount()`
140140
- :method:`db.collection.count()`
141141

142-
.. important::
142+
Behavior
143+
--------
143144

144-
- Avoid using the :dbcommand:`count` and its wrapper methods
145-
without a query predicate (note:
146-
:method:`db.collection.estimatedDocumentCount()` does not take
147-
a query predicate) since without the query predicate, these
148-
operations return results based on the collection's metadata,
149-
which may result in an approximate count. In particular,
145+
.. _count-command-behavior-query-predicate:
150146

151-
- On a sharded cluster, the resulting count will not correctly
152-
filter out :term:`orphaned documents <orphaned document>`.
147+
Inaccurate Counts Without Query Predicate
148+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
153149

154-
- :ref:`After an unclean shutdown <count-accuracy-shutdown>`,
155-
the count may be incorrect.
150+
When you call :dbcommand:`count` without a query predicate, you may
151+
receive inaccurate document counts. Without a query predicate,
152+
:dbcommand:`count` commands return results based on the collection's
153+
metadata, which may result in an approximate count. In particular,
156154

157-
- For counts based on collection metadata, see also
158-
:ref:`collStats pipeline stage with the count <collstat-count>`
159-
option.
155+
- On a sharded cluster, the resulting count will not correctly
156+
filter out :term:`orphaned documents <orphaned document>`.
160157

161-
Behavior
162-
--------
158+
- After an unclean shutdown or :ref:`file copy based initial sync
159+
<replica-set-initial-sync-file-copy-based>`, the count may be
160+
incorrect.
161+
162+
For counts based on collection metadata, see also
163+
:ref:`collStats pipeline stage with the count <collstat-count>`
164+
option.
163165

164166
Count and Transactions
165167
~~~~~~~~~~~~~~~~~~~~~~

source/reference/method/cursor.count.txt

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33,25 +33,6 @@ Definition
3333
matching documents. The operation does not perform the query but
3434
instead counts the results that would be returned by the query.
3535

36-
.. important::
37-
38-
- Avoid using :method:`~cursor.count()` if the
39-
:method:`~db.collection.find()` operation is run without a
40-
query predicate since without the query predicate, these
41-
:method:`~cursor.count()` returns results based on the
42-
collection's metadata, which may result in an approximate
43-
count. In particular,
44-
45-
- On a sharded cluster, the resulting count will not correctly
46-
filter out :term:`orphaned documents <orphaned document>`.
47-
48-
- After an unclean shutdown, the count may be
49-
incorrect.
50-
51-
- For counts based on collection metadata, see also
52-
:ref:`collStats pipeline stage with the count <collstat-count>`
53-
option.
54-
5536

5637
The :method:`~cursor.count()` method has the following
5738
prototype form:
@@ -105,6 +86,29 @@ Definition
10586
Behavior
10687
--------
10788

89+
.. _count-cursor-behavior-query-predicate:
90+
91+
Inaccurate Counts Without Query Predicate
92+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
93+
94+
When you call :method:`~cursor.count()` on a
95+
:method:`~db.collection.find()` operation which does not specify a query
96+
predicate, the :method:`~cursor.count()` method can return inaccurate
97+
document counts. These :method:`~cursor.count()` methods return results
98+
based on the collection's metadata, which may result in an approximate
99+
count. In particular,
100+
101+
- On a sharded cluster, the resulting count will not correctly
102+
filter out :term:`orphaned documents <orphaned document>`.
103+
104+
- After an unclean shutdown or :ref:`file copy based initial sync
105+
<replica-set-initial-sync-file-copy-based>`, the count may be
106+
incorrect.
107+
108+
For counts based on collection metadata, see also
109+
:ref:`collStats pipeline stage with the count <collstat-count>`
110+
option.
111+
108112
Count and Transactions
109113
~~~~~~~~~~~~~~~~~~~~~~
110114

source/reference/method/db.collection.count.txt

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33,25 +33,6 @@ Definition
3333
:method:`~db.collection.find()` operation but instead counts and
3434
returns the number of results that match a query.
3535

36-
.. important::
37-
38-
- Avoid using the :method:`db.collection.count()` method without
39-
a query predicate since without the query predicate, the method
40-
returns results based on the collection's metadata, which may
41-
result in an approximate count. In particular,
42-
43-
- On a sharded cluster, the resulting count will not correctly
44-
filter out :term:`orphaned documents <orphaned document>`.
45-
46-
- :ref:`After an unclean shutdown
47-
<collection-count-accuracy-shutdown>`, the count may be
48-
incorrect.
49-
50-
- For counts based on collection metadata, see also
51-
:ref:`collStats pipeline stage with the count <collstat-count>`
52-
option.
53-
54-
5536
.. list-table::
5637
:header-rows: 1
5738
:widths: 20 20 80
@@ -162,6 +143,28 @@ Definition
162143
Behavior
163144
--------
164145

146+
.. _count-method-behavior-query-predicate:
147+
148+
Inaccurate Counts Without Query Predicate
149+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
150+
151+
When you call :method:`~db.collection.count()` without a query
152+
predicate, you may receive inaccurate document counts. Without a query
153+
predicate, :method:`~db.collection.count()` methods return results based
154+
on the collection's metadata, which may result in an approximate count.
155+
In particular,
156+
157+
- On a sharded cluster, the resulting count will not correctly
158+
filter out :term:`orphaned documents <orphaned document>`.
159+
160+
- After an unclean shutdown or :ref:`file copy based initial sync
161+
<replica-set-initial-sync-file-copy-based>`, the count may be
162+
incorrect.
163+
164+
For counts based on collection metadata, see also
165+
:ref:`collStats pipeline stage with the count <collstat-count>`
166+
option.
167+
165168
Count and Transactions
166169
~~~~~~~~~~~~~~~~~~~~~~
167170

0 commit comments

Comments
 (0)