Skip to content

PHPLIB-434: Add note about performance of countDocuments #735

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/reference/method/MongoDBCollection-countDocuments.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ obtain the result. If a ``filter`` parameter is given, this is converted into
a ``$match`` pipeline operator. Optional ``$skip`` and ``$limit`` stages are
added between ``$match`` and ``group`` if present in the options.

.. note::

This method counts documents on the server side. To obtain an approximate
total number of documents without filters, the
:phpmethod:`MongoDB\\Collection::estimatedDocumentCount()` method can be
used. This method estimates the number of documents based on collection
metadata, thus sacrificing accuracy for performance.

Since this method uses an aggregation pipeline, some query operators accepted
within a :phpmethod:`MongoDB\\Collection::count()` ``filter`` cannot be used.
Consider the following alternatives to these restricted operators:
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/method/MongoDBCollection-createIndex.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ The output would then resemble::
Create a Partial Index
~~~~~~~~~~~~~~~~~~~~~~

The following example adds a :manual:`partial index </core/index-parital>` on
The following example adds a :manual:`partial index </core/index-partial>` on
the ``borough`` field in the ``restaurants`` collection in the ``test``
database. The partial index indexes only documents where the ``borough`` field
exists.
Expand Down