- Administration >
- Administration Reference >
- Database Profiler Output
Database Profiler Output¶
On this page
The database profiler captures data information about read and write operations, cursor operations, and database commands. To configure the database profile and set the thresholds for capturing profile data, see the Analyze Performance of Database Operations section.
The database profiler writes data in the system.profile
collection,
which is a capped collection. To view the profiler’s output,
use normal MongoDB queries on the system.profile
collection.
Note
Because the database profiler writes data to the
system.profile
collection in a
database, the profiler will profile some write activity, even for
databases that are otherwise read-only.
Example system.profile
Document¶
The documents in the system.profile
collection have the following form. This
example document reflects an update operation:
Output Reference¶
For any single operation, the documents created by the database profiler will include a subset of the following fields. The precise selection of fields in these documents depends on the type of operation.
-
system.profile.
op
¶ The type of operation. The possible values are:
insert
query
update
remove
getmore
command
-
system.profile.
ns
¶ The namespace the operation targets. Namespaces in MongoDB take the form of the database, followed by a dot (
.
), followed by the name of the collection.
-
system.profile.
query
¶ The query document used.
Changed in version 2.6.11: For
"getmore"
operations on cursors returned from adb.collection.find()
or adb.collection.aggregate()
, thequery
field contains respectively the query predicate or the issuedaggregate
command document. For details on theaggregate
command document, see theaggregate
reference page.
-
system.profile.
command
¶ The command operation.
-
system.profile.
cursorid
¶ The ID of the cursor accessed by a
getmore
operation.
-
system.profile.
ntoreturn
¶ Changed in version 2.2: In 2.0, MongoDB includes this field for
query
andcommand
operations. In 2.2, this information MongoDB also includes this field forgetmore
operations.The number of documents the operation specified to return. For example, the
profile
command would return one document (a results document) so thentoreturn
value would be1
. Thelimit(5)
command would return five documents so thentoreturn
value would be5
.If the
ntoreturn
value is0
, the command did not specify a number of documents to return, as would be the case with a simplefind()
command with no limit specified.
-
system.profile.
ntoskip
¶ New in version 2.2.
The number of documents the
skip()
method specified to skip.
-
system.profile.
nscanned
¶ The number of documents that MongoDB scans in the index in order to carry out the operation.
In general, if
nscanned
is much higher thannreturned
, the database is scanning many objects to find the target objects. Consider creating an index to improve this.
-
system.profile.
nscannedObjects
¶ The number of documents that MongoDB scans from the collection in order to carry out the operation.
-
system.profile.
moved
¶ This field appears with a value of
true
when an update operation moved one or more documents to a new location on disk. If the operation did not result in a move, this field does not appear. Operations that result in a move take more time than in-place updates and typically occur as a result of document growth.
-
system.profile.
nmoved
¶ New in version 2.2.
The number of documents the operation moved on disk. This field appears only if the operation resulted in a move. The field’s implicit value is zero, and the field is present only when non-zero.
-
system.profile.
scanAndOrder
¶ scanAndOrder
is a boolean that istrue
when a query cannot use the order of documents in the index for returning sorted results: MongoDB must sort the documents after it receives the documents from a cursor.If
scanAndOrder
isfalse
, MongoDB can use the order of the documents in an index to return sorted results.
-
system.profile.
ndeleted
¶ The number of documents deleted by the operation.
-
system.profile.
ninserted
¶ The number of documents inserted by the operation.
-
system.profile.
nMatched
¶ New in version 2.6.
The number of documents that match the
system.profile.query
condition for the update operation.
-
system.profile.
nModified
¶ New in version 2.6.
The number of documents modified by the update operation.
-
system.profile.
upsert
¶ A boolean that indicates the update operation’s
upsert
option value. Only appears ifupsert
is true.
-
system.profile.
keyUpdates
¶ New in version 2.2.
The number of index keys the update changed in the operation. Changing an index key carries a small performance cost because the database must remove the old key and inserts a new key into the B-tree index.
-
system.profile.
numYield
¶ New in version 2.2.
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 the FAQ on when operations yield.
-
system.profile.
lockStats
¶ New in version 2.2.
The time in microseconds the operation spent acquiring and holding locks. This field reports data for the following lock types:
R
- global read lockW
- global write lockr
- database-specific read lockw
- database-specific write lock
-
system.profile.lockStats.
timeLockedMicros
¶ The time in microseconds the operation held a specific lock. For operations that require more than one lock, like those that lock the
local
database to update the oplog, this value may be longer than the total length of the operation (i.e.millis
.)
-
system.profile.lockStats.
timeAcquiringMicros
¶ The time in microseconds the operation spent waiting to acquire a specific lock.
-
system.profile.
nreturned
¶ The number of documents returned by the operation.
-
system.profile.
responseLength
¶ The length in bytes of the operation’s result document. A large
responseLength
can affect performance. To limit the size of the result document for a query operation, you can use any of the following:Note
When MongoDB writes query profile information to the log, the
responseLength
value is in a field namedreslen
.
-
system.profile.
millis
¶ The time in milliseconds from the perspective of the
mongod
from the beginning of the operation to the end of the operation.
-
system.profile.
execStats
¶ New in version 2.6.
A document that contains the execution statistics of the query operation. For other operations, the value is an empty document.
The
system.profile.execStats
presents the staticstics as a tree; each node provides the statistics for the operation executed during that stage of the query operation.Note
The following fields list for
execStats
is not meant to be exhaustive as the returned fields vary per stage.-
system.profile.execStats.
type
¶ The descriptive name for the operation performed as part of the query execution; e.g.
COLLSCAN
for a collection scanIXSCAN
for scanning index keysFETCH
for retrieving documents
-
system.profile.execStats.
children
¶ An array that contains statistics for the operations that are the children of the current stage.
-
-
system.profile.
ts
¶ The timestamp of the operation.
-
system.profile.
client
¶ The IP address or hostname of the client connection where the operation originates.
For some operations, such as
db.eval()
, the client is0.0.0.0:0
instead of an actual client.
-
system.profile.
allUsers
¶ An array of authenticated user information (user name and database) for the session. See also Client Authentication.
-
system.profile.
user
¶ The authenticated user who ran the operation. If the operation was not run by an authenticated user, this field’s value is an empty string.