/
profile.txt
69 lines (49 loc) · 2.27 KB
/
profile.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
=======
profile
=======
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
.. dbcommand:: profile
Use the :dbcommand:`profile` command to enable, disable, or change
the query profiling level. This allows administrators to capture
data regarding performance. The database profiling system can
impact performance and can allow the server to write the contents
of queries to the log. Your deployment should carefully consider the
security implications of this. The profiler is off by default.
.. |command| replace:: ``profile``
.. include:: /includes/fact-dbcommand.rst
The :dbcommand:`profile` command has the following syntax:
.. code-block:: javascript
{ profile: <level> }
The following profiling levels are available:
========= ==============================================
**Level** **Setting**
--------- ----------------------------------------------
-1 No change. Returns the current profile level.
0 Off. No profiling. The default profiler level.
1 On. Only includes slow operations.
2 On. Includes all operations.
========= ==============================================
You may optionally set a threshold in milliseconds for profiling using
the ``slowms`` option, as follows:
.. code-block:: javascript
{ profile: 1, slowms: 200 }
:binary:`~bin.mongod` writes the output of the database profiler to the
``system.profile`` collection.
:binary:`~bin.mongod` records queries that take longer than
the :setting:`~operationProfiling.slowOpThresholdMs` to the server log even when the database profiler is
not active.
.. seealso:: Additional documentation regarding :ref:`Database Profiling <database-profiling>`.
.. seealso:: ":method:`db.getProfilingStatus()`" and
":method:`db.setProfilingLevel()`" provide wrappers
around this functionality in the :binary:`~bin.mongo`
shell.
.. note::
This command obtains a write lock on the affected database and
blocks other operations until it has completed. However, the write
lock is only held while enabling or disabling the
profiler. This is typically a short operation.