-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathPlanCache.clearPlansByQuery.txt
121 lines (74 loc) · 2.84 KB
/
PlanCache.clearPlansByQuery.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
=============================
PlanCache.clearPlansByQuery()
=============================
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
Definition
----------
.. method:: PlanCache.clearPlansByQuery( <query>, <projection>, <sort> )
Clears the cached query plans for the specified :term:`plan cache query shape`.
.. |dbcommand| replace:: :dbcommand:`planCacheClear` command
.. include:: /includes/fact-mongosh-shell-method-alt
The method is only available from the :method:`plan cache object
<db.collection.getPlanCache()>` of a specific collection; i.e.
.. code-block:: javascript
db.collection.getPlanCache().clearPlansByQuery( <query>, <projection>, <sort> )
The :method:`PlanCache.clearPlansByQuery()` method accepts the
following parameters:
.. list-table::
:header-rows: 1
:widths: 20 20 80
* - Parameter
- Type
- Description
* - ``query``
- document
- The query predicate of the plan cache query shape. Only the structure
of the predicate, including the field names, are significant to the
shape; the values in the query predicate are insignificant.
* - ``projection``
- document
- Optional. The projection associated with the plan cache query shape. Required if
specifying the ``sort`` parameter.
* - ``sort``
- document
- Optional. The sort associated with the plan cache query shape.
To see the query shapes for which cached query plans exist, see
:ref:`planCacheStats-examples`.
.. include:: /includes/persistent-query-settings-avoid-index-filters-intro.rst
Compatibility
-------------
This method is available in deployments hosted in the following environments:
.. include:: /includes/fact-environments-atlas-only.rst
.. include:: /includes/fact-environments-onprem-only.rst
Required Access
---------------
On systems running with :setting:`~security.authorization`, a user must have access that
includes the :authaction:`planCacheWrite` action.
Example
-------
If a collection ``orders`` has the following plan cache query shape:
.. code-block:: javascript
{
"query" : { "qty" : { "$gt" : 10 } },
"sort" : { "ord_date" : 1 },
"projection" : { },
"planCacheShapeHash" : "9AAD95BE"
}
.. warning::
.. include:: /includes/plan-cache-rename.rst
The following operation removes the query plan cached for the shape:
.. code-block:: javascript
db.orders.getPlanCache().clearPlansByQuery(
{ "qty" : { "$gt" : 10 } },
{ },
{ "ord_date" : 1 }
)
.. seealso::
- :method:`db.collection.getPlanCache()`
- ``PlanCache.listQueryShapes()``
- :method:`PlanCache.clear()`