From 2cd8079c50a2647340207981a2440d8580a2658d Mon Sep 17 00:00:00 2001 From: Andreas Braun Date: Mon, 6 Apr 2020 13:51:41 +0200 Subject: [PATCH 1/2] PHPLIB-434: Add note about performance of countDocuments --- .../reference/method/MongoDBCollection-countDocuments.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/reference/method/MongoDBCollection-countDocuments.txt b/docs/reference/method/MongoDBCollection-countDocuments.txt index 61e292e69..b66171c27 100644 --- a/docs/reference/method/MongoDBCollection-countDocuments.txt +++ b/docs/reference/method/MongoDBCollection-countDocuments.txt @@ -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: From 89721f07495bc88f1c5000f517f6795badea23d1 Mon Sep 17 00:00:00 2001 From: Andreas Braun Date: Mon, 6 Apr 2020 13:51:57 +0200 Subject: [PATCH 2/2] Fix typo in index documentation --- docs/reference/method/MongoDBCollection-createIndex.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/reference/method/MongoDBCollection-createIndex.txt b/docs/reference/method/MongoDBCollection-createIndex.txt index ff4150eac..6385b578b 100644 --- a/docs/reference/method/MongoDBCollection-createIndex.txt +++ b/docs/reference/method/MongoDBCollection-createIndex.txt @@ -73,7 +73,7 @@ The output would then resemble:: Create a Partial Index ~~~~~~~~~~~~~~~~~~~~~~ -The following example adds a :manual:`partial index ` on +The following example adds a :manual:`partial index ` on the ``borough`` field in the ``restaurants`` collection in the ``test`` database. The partial index indexes only documents where the ``borough`` field exists.