Skip to content

Commit 72f22b7

Browse files
kennethdyerKenneth P. J. Dyerianf-mongodb
authored
DOCS-16051 plan cache stats all hosts (#4845)
* DOCS-16051 planCacheStats allHosts option * Adds allHosts option * Adds allHosts option * Reworks to bullet list * Minor edits * Fixes per Ian Co-authored-by: ianf-mongodb <[email protected]> * Fixes per Ian --------- Co-authored-by: Kenneth P. J. Dyer <[email protected]> Co-authored-by: ianf-mongodb <[email protected]>
1 parent 8f78a2a commit 72f22b7

File tree

1 file changed

+43
-8
lines changed

1 file changed

+43
-8
lines changed

source/reference/operator/aggregation/planCacheStats.txt

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,58 @@ Definition
1919
collection. The stage returns a document for each plan cache entry.
2020

2121
The ``$planCacheStats`` stage must be the first stage in the
22-
pipeline. The stage takes an empty document as a parameter and has
23-
the following syntax:
22+
pipeline. The stage has the following syntax:
2423

2524
.. code-block:: javascript
2625

27-
{ $planCacheStats: { } }
26+
{
27+
$planCacheStats: {
28+
allHosts: <boolean>
29+
}
30+
}
31+
32+
The ``$planCacheStats`` aggregation stage has the following options:
33+
34+
.. list-table::
35+
:header-rows: 1
36+
:widths: 25 75
37+
38+
* - Option
39+
- Description
40+
* - ``allHosts``
41+
- Configures how the ``$planCacheStats`` aggregation stage targets
42+
nodes in a sharded cluster.
43+
44+
- If ``true``, :program:`mongos` broadcasts the ``$planCacheStats``
45+
aggregation stage to all nodes (primary and secondaries) for each
46+
affected shard that contains one or more chunks from the target
47+
collection.
48+
49+
- If ``false``, the ``$planCacheStats`` aggregation stage follows the
50+
:ref:`read-preference` and only retrieves the plan cache from the
51+
targeted replica set primary.
52+
53+
.. note::
54+
55+
Replica sets and standalone servers return an error during pipeline
56+
parsing if ``allHosts`` is set to ``true``. The option is only
57+
available to sharded clusters.
58+
59+
Default: ``false``
60+
61+
.. versionadded:: 7.1
2862

2963
.. seealso::
3064

31-
:ref:`query-plans-query-optimization`
65+
:ref:`query-plans-query-optimization`
3266

3367
Considerations
3468
--------------
3569

3670
Pipeline
3771
~~~~~~~~
3872

39-
``$planCacheStats`` must be the first stage in an aggregation
40-
pipeline.
73+
``$planCacheStats`` must be the first stage in an aggregation pipeline.
4174

4275
Restrictions
4376
~~~~~~~~~~~~
@@ -64,12 +97,14 @@ Redaction
6497
~~~~~~~~~
6598

6699
When using :ref:`Queryable Encryption <qe-manual-feature-qe>`, the
67-
``$planCacheStats`` stage omits operations against encrypted collections, even though the operations are cached as normal.
100+
``$planCacheStats`` stage omits operations against encrypted collections, even
101+
though the operations are cached as normal.
68102

69103
Read Preference
70104
~~~~~~~~~~~~~~~
71105

72-
``$planCacheStats`` observes the :ref:`read preference
106+
When the ``allHosts`` option is set to ``false``,
107+
:pipeline:`$planCacheStats` follows the :ref:`read preference
73108
<read-preference>` in selecting the host(s) from which to return
74109
the plan cache information.
75110

0 commit comments

Comments
 (0)