-
Notifications
You must be signed in to change notification settings - Fork 1.7k
DOCS-850 database profiler documentation #458
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
47c53cd
DOCS-850 database profiler documentation
06aee18
DOCS-850 review edits to db profiler reference page
5895c6d
DOCS-850 review edits to db profiler tutorial
e79e084
DOCS-850 typo
b608740
DOCS-850 minor
c6485c6
DOCS-850 minor review edits
4eef784
DOCS-850 minor
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,220 @@ | ||
======================== | ||
Database Profiler Output | ||
======================== | ||
|
||
.. default-domain:: mongodb | ||
|
||
The database profiler logs information about read and write operations, | ||
cursor operations, and database commands. To set the level of logging | ||
for the database profiler, see | ||
:doc:`/tutorial/manage-the-database-profiler`. | ||
|
||
The database profiler logs data in the ``system.profile`` collection, | ||
which is a :term:`capped collection`. To view the profiler's output, | ||
query this collection. | ||
|
||
If you turn on profiling operations on a read-only database, you will still see write | ||
operations in the ``system.profile`` collection because the database | ||
profiler itself performs writes to ``system.profile``. | ||
|
||
Example Output | ||
-------------- | ||
|
||
The following is an example of database profiler output for an update | ||
operation. | ||
|
||
.. code-block:: javascript | ||
|
||
{ | ||
"ts" : ISODate("2012-12-10T19:31:28.977Z"), | ||
"op" : "update", | ||
"ns" : "social.users", | ||
"query" : { | ||
"name" : "jane" | ||
}, | ||
"updateobj" : { | ||
"$set" : { | ||
"likes" : [ | ||
"basketball", | ||
"trekking" | ||
] | ||
} | ||
}, | ||
"nscanned" : 8, | ||
"moved" : true, | ||
"nmoved" : 1, | ||
"nupdated" : 1, | ||
"keyUpdates" : 0, | ||
"numYield" : 0, | ||
"lockStats" : { | ||
"timeLockedMicros" : { | ||
"r" : NumberLong(0), | ||
"w" : NumberLong(258) | ||
}, | ||
"timeAcquiringMicros" : { | ||
"r" : NumberLong(0), | ||
"w" : NumberLong(7) | ||
} | ||
}, | ||
"millis" : 0, | ||
"client" : "127.0.0.1", | ||
"user" : "" | ||
} | ||
|
||
Output Reference | ||
---------------- | ||
|
||
The database profiler reports the following values. The set of values | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The documents created by the database profiler have the following fields. Each profiling report will have a different subset of these fields depending on the operation. |
||
reported for a given operation depends on the operation: | ||
|
||
.. stats:: ts | ||
|
||
The timestamp of the operation. | ||
|
||
.. stats:: op | ||
|
||
The type of operation. The possible values are: | ||
|
||
- ``insert`` | ||
- ``query`` | ||
- ``update`` | ||
- ``remove`` | ||
- ``getmore`` | ||
- ``command`` | ||
|
||
.. stats:: ns | ||
|
||
The :term:`namespace` the operation targets. MongoDB forms | ||
namespaces using the name of the :term:`database` and the name of | ||
the :term:`collection`. | ||
|
||
.. stats:: query | ||
|
||
The query criteria used. | ||
|
||
.. stats:: command | ||
|
||
The command used. | ||
|
||
.. stats:: updateobj | ||
|
||
The :ref:`update document <documents-update-actions>` passed in | ||
during an :doc:`update </applications/update>` operation. | ||
|
||
.. stats:: cursorid | ||
|
||
The ID of the cursor accessed by a ``getmore`` operation. | ||
|
||
.. stats:: ntoreturn | ||
|
||
The number of documents the operation specified to return. For | ||
example, the :dbcommand:`profile` command would return one document | ||
(a results document) so the ``ntoreturn`` value would be ``1``. The | ||
:method:`limit(5) <cursor.limit()>` command would return five | ||
documents so the ``ntoreturn`` value would be ``5``. | ||
|
||
If the ``ntoreturn`` value is ``0``, the command did not specify a | ||
number of documents to return, as would be the case with a simple | ||
:method:`find() <db.collection.find()>` command with no limit | ||
specified. | ||
|
||
.. stats:: ntoskip | ||
|
||
The number of documents the :method:`skip() <cursor.skip()>` method | ||
specified to skip. | ||
|
||
.. stats:: nscanned | ||
|
||
The number of documents that were scanned in the :doc:`index </indexes>` in order to | ||
carry out the operation. | ||
|
||
In general, if ``nscanned`` is much higher than ``nreturned``, the | ||
database is scanning many objects to find the target objects. | ||
Consider creating an index to improve this. | ||
|
||
.. stats:: moved | ||
|
||
A value of ``true`` indicates that the update operation moved one or | ||
more documents to a new location on disk. This is slower than an | ||
in-place update. This should only happen if the document grows in size. | ||
|
||
.. stats:: nmoved | ||
|
||
The number of documents moved on disk by the operation. | ||
|
||
.. stats:: nupdated | ||
|
||
The number of documents updated by the operation. | ||
|
||
.. stats:: keyUpdates | ||
|
||
The number of :doc:`index </indexes>` keys the update changed. Changing an index key | ||
carries a small performance cost. The database must remove the old | ||
key and insert a new key into the B-tree index. | ||
|
||
.. stats:: numYield | ||
|
||
The number of times the operation yielded to allow other operations | ||
to complete. Typically, operations yield when they need access to | ||
data that MongoDB has not yet fully read into memory. This allows | ||
other operations that have data in memory to complete while MongoDB | ||
reads in data for the yielding operation. For more information, | ||
see :ref:`the FAQ on when operations yield <faq-concurrency-yielding>`. | ||
|
||
.. stats:: lockStats | ||
|
||
The time in microseconds the operation spent acquiring and holding | ||
locks. This field reports data for the following lock types: | ||
|
||
- ``R`` - global read lock | ||
- ``W`` - global write lock | ||
- ``r`` - database-specific read lock | ||
- ``w`` - database-specific write lock | ||
|
||
.. stats:: lockStats.timeLockedMicros | ||
|
||
The time in microseconds the operation held a specific lock. | ||
|
||
.. stats:: lockStats.timeAcquiringMicros | ||
|
||
The time in microseconds the operation spent waiting to acquire a | ||
specific lock. | ||
|
||
.. stats:: nreturned | ||
|
||
The number of documents returned by the operation. | ||
|
||
.. stats:: responseLength | ||
|
||
The length in bytes of the operation's result document. A large | ||
``responseLength`` can affect performance. To limit the size of a the | ||
result document for a query operation, you can use any of the | ||
following: | ||
|
||
- :ref:`Projections <read-operations-projection>` | ||
- :method:`The limit() method <cursor.limit()>` | ||
- :method:`The batchSize() method <cursor.batchSize()>` | ||
|
||
.. stats:: millis | ||
|
||
The time in milliseconds for the server to perform the operation. | ||
This time does not include network time nor time to acquire the lock. | ||
|
||
.. stats:: client | ||
|
||
The IP address or hostname of the client connection where the | ||
operation originates. | ||
|
||
For some commands, such as :method:`db.eval()`, the client is | ||
``0.0.0.0:0`` instead of an actual client. | ||
|
||
.. stats:: user | ||
|
||
The authenticated user who ran the operation. | ||
|
||
.. todo Test what values appear for authenticated users and add that info. | ||
When we do, we can add back this: "If the operation was not run by an | ||
authenticated user, this field's value is an empty string." | ||
|
||
.. todo Consider adding documentation to our manual on the | ||
"internal user" used by replication |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
captures data regarding all database operations.