-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
killCursors.txt
145 lines (99 loc) · 2.92 KB
/
killCursors.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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
===========
killCursors
===========
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
.. versionadded:: 3.2
Definition
----------
.. dbcommand:: killCursors
Kills the specified cursor or cursors for a collection. MongoDB
drivers use the :dbcommand:`killCursors` command as part of the
client-side cursor implementation.
.. note::
In general, applications should not use the
:dbcommand:`killCursors` command directly.
.. |command| replace:: killCursors
The ``killCursors`` command must be run against the database of the
collection whose cursors you wish to kill.
.. include:: /includes/fact-dbcommand.rst
The command has the following form:
.. code-block:: javascript
db.runCommand( { "killCursors": <collection>, "cursors": [ <cursor id1>, ... ] } )
.. list-table::
:header-rows: 1
:widths: 20 20 80
* - Field
- Type
- Description
* - ``killCursors``
- string
- The name of the collection.
* - ``cursors``
- array
- The ids of the cursors to kill.
Example
-------
Consider the following :dbcommand:`find` operation on the
``test.restaurants`` collection:
.. code-block:: javascript
use test
db.runCommand(
{ find: "restaurants",
filter: { stars: 5 },
projection: { name: 1, rating: 1, address: 1 },
sort: { name: 1 },
batchSize: 5
}
)
which returns the following:
.. code-block:: javascript
{
"waitedMS" : NumberLong(0),
"cursor" : {
"firstBatch" : [
{
"_id" : ObjectId("57506d63f578028074723dfd"),
"name" : "Cakes and more"
},
{
"_id" : ObjectId("57506d63f578028074723e0b"),
"name" : "Pies and things"
},
{
"_id" : ObjectId("57506d63f578028074723e1d"),
"name" : "Ice Cream Parlour"
},
{
"_id" : ObjectId("57506d63f578028074723e65"),
"name" : "Cream Puffs"
},
{
"_id" : ObjectId("57506d63f578028074723e66"),
"name" : "Cakes and Rolls"
}
],
"id" : NumberLong("18314637080"),
"ns" : "test.restaurants"
},
"ok" : 1
}
To kill this cursor, use the :dbcommand:`killCursors` command.
.. code-block:: javascript
use test
db.runCommand( { killCursors: "restaurants", cursors: [ NumberLong("18314637080") ] } )
:dbcommand:`killCursors` returns the following operation details:
.. code-block:: javascript
{
"cursorsKilled" : [
NumberLong("18314637080")
],
"cursorsNotFound" : [ ],
"cursorsAlive" : [ ],
"cursorsUnknown" : [ ],
"ok" : 1
}