@@ -19,25 +19,58 @@ Definition
19
19
collection. The stage returns a document for each plan cache entry.
20
20
21
21
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:
24
23
25
24
.. code-block:: javascript
26
25
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
28
62
29
63
.. seealso::
30
64
31
- :ref:`query-plans-query-optimization`
65
+ :ref:`query-plans-query-optimization`
32
66
33
67
Considerations
34
68
--------------
35
69
36
70
Pipeline
37
71
~~~~~~~~
38
72
39
- ``$planCacheStats`` must be the first stage in an aggregation
40
- pipeline.
73
+ ``$planCacheStats`` must be the first stage in an aggregation pipeline.
41
74
42
75
Restrictions
43
76
~~~~~~~~~~~~
@@ -64,12 +97,14 @@ Redaction
64
97
~~~~~~~~~
65
98
66
99
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.
68
102
69
103
Read Preference
70
104
~~~~~~~~~~~~~~~
71
105
72
- ``$planCacheStats`` observes the :ref:`read preference
106
+ When the ``allHosts`` option is set to ``false``,
107
+ :pipeline:`$planCacheStats` follows the :ref:`read preference
73
108
<read-preference>` in selecting the host(s) from which to return
74
109
the plan cache information.
75
110
0 commit comments