-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
planCacheListPlans.txt
119 lines (73 loc) · 2.47 KB
/
planCacheListPlans.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
==================
planCacheListPlans
==================
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
Definition
----------
.. dbcommand:: planCacheListPlans
.. versionadded:: 2.6
Displays the cached query plans for the specified :term:`query
shape`.
.. include:: /includes/fact-query-optimizer-cache-behavior.rst
The :binary:`~bin.mongo` shell provides the wrapper
:method:`PlanCache.getPlansByQuery()` for this command.
The :dbcommand:`planCacheListPlans` command has the following syntax:
.. code-block:: javascript
db.runCommand(
{
planCacheListPlans: <collection>,
query: <query>,
sort: <sort>,
projection: <projection>
}
The :dbcommand:`planCacheListPlans` command has the following field:
.. list-table::
:header-rows: 1
:widths: 20 20 80
* - Field
- Type
- Description
* - ``query``
- document
- The query predicate of the :term:`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 :term:`query shape`.
* - ``sort``
- document
- Optional. The sort associated with the :term:`query shape`.
To see the query shapes for which cached query plans exist, use the
:dbcommand:`planCacheListQueryShapes` command.
Required Access
---------------
On systems running with :setting:`~security.authorization`, a user must have access that
includes the :authaction:`planCacheRead` action.
Example
-------
If a collection ``orders`` has the following query shape:
.. code-block:: javascript
{
"query" : { "qty" : { "$gt" : 10 } },
"sort" : { "ord_date" : 1 },
"projection" : { }
}
The following operation displays the query plan cached for the shape:
.. code-block:: javascript
db.runCommand(
{
planCacheListPlans: "orders",
query: { "qty" : { "$gt" : 10 } },
sort: { "ord_date" : 1 }
}
)
.. seealso::
- :dbcommand:`planCacheListQueryShapes`
- :method:`PlanCache.getPlansByQuery()`
- :method:`PlanCache.listQueryShapes()`