- Administration >
- MongoDB Performance >
- Database Profiler >
- 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 Database Profiler 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.
Changed in version 3.4.
currentOp and the
database profiler report the same
basic diagnostic information for all CRUD operations, including the
following:
aggregatecountdeletedistinctfind(OP_QUERY andcommand)findAndModifygeoNeargetMore(OP_GET_MORE andcommand)groupinsertmapReduceupdate
These operations are also included in the logging of
slow queries (see slowOpThresholdMs for
more information about slow query logging).
Example system.profile Document¶
The documents in the system.profile
collection have the following form. This example document reflects a
find operation on a standalone mongod:
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.
Changed in version 3.2.0: system.profile.query.skip replaces the system.profile.ntoskip
field.
Changed in version 3.2.0: The information in the system.profile.ntoreturn field has been
replaced by two separate fields, system.profile.query.limit and
system.profile.query.batchSize. Older drivers or older versions
of the mongo shell may still use ntoreturn; this will
appear as system.profile.query.ntoreturn.
Note
For the output specific to the version of your MongoDB, refer to the appropriate version of the MongoDB Manual.
-
system.profile.op¶ The type of operation. The possible values are:
commandcountdistinctgeoNeargetMoregroupinsertmapReducequeryremoveupdate
-
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, or for an insert operation, the inserted document. If the document exceeds 50 kilobytes, the value is a string summary of the object. If the string summary exceeds 50 kilobytes, the string summary is truncated, denoted with an ellipsis (
...) at the end of the string.Changed in version 3.0.4: For
"getmore"operations on cursors returned from adb.collection.find()or adb.collection.aggregate(), thequeryfield contains respectively the query predicate or the issuedaggregatecommand document. For details on theaggregatecommand document, see theaggregatereference page.
-
system.profile.command¶ The command operation. If the command document exceeds 50 kilobytes, the value is a string summary of the object. If the string summary exceeds 50 kilobytes, the string summary is truncated, denoted with an ellipsis (
...) at the end of the string.
-
system.profile.updateobj¶ The
<update>document passed in during an update operation. If the document exceeds 50 kilobytes, the value is a string summary of the object. If the string summary exceeds 50 kilobytes, the string summary is truncated, denoted with an ellipsis (...) at the end of the string.
-
system.profile.cursorid¶ The ID of the cursor accessed by a
queryandgetmoreoperations.
-
system.profile.keysExamined¶ Changed in version 3.2.0.
Renamed from
system.profile.nscanned. The number of index keys that MongoDB scanned in order to carry out the operation.In general, if
keysExaminedis much higher thannreturned, the database is scanning many index keys to find the result documents. Consider creating or adjusting indexes to improve query performance..Changed in version 3.4.
keysExaminedis available for the following commands and operations:
-
system.profile.docsExamined¶ Changed in version 3.2.0: Renamed from
system.profile.nscannedObjects.The number of documents in the collection that MongoDB scanned in order to carry out the operation.
Changed in version 3.4.
docsExaminedis available for the following commands and operations:
-
system.profile.moved¶ Removed in 3.4.
Changed in version 3.0.0: Only appears when using the MMAPv1 storage engine.
This field appears with a value of
truewhen 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¶ Changed in version 3.0.0: Only appears when using the MMAPv1 storage engine.
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.hasSortStage¶ Changed in version 3.2.0: Renamed from
system.profile.scanAndOrder.hasSortStageis a boolean that istruewhen a query cannot use the ordering in the index to return the requested sorted results; i.e. MongoDB must sort the documents after it receives the documents from a cursor. The field only appears when the value istrue.Changed in version 3.4.
hasSortStageis available for the following commands and operations:find(OP_QUERY andcommand)getMore(OP_GET_MORE andcommand)findAndModifymapReduceaggregate
-
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.querycondition 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
upsertoption value. Only appears ifupsertis true.
-
system.profile.fastmodinsert¶ Deprecated since version 3.4.
Records the number of update operations that match all of the following criteria:
- Are upserts (that result in an insert)
- Do not use a modifier operation such as
$set
-
system.profile.fromMultiPlanner¶ New in version 3.2.5.
A boolean that indicates whether the query planner evaluated multiple plans before choosing the winning execution plan for the query.
Only present when value is
true.
-
system.profile.replanned¶ New in version 3.2.5.
A boolean that indicates whether the query system evicted a cached plan and re-evaluated all candidate plans.
Only present when value is
true.
-
system.profile.keysInserted¶ The number of index keys inserted for a given write operation.
-
system.profile.keysDeleted¶ Removed in 3.4.
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.writeConflicts¶ New in version 3.0.0.
The number of conflicts encountered during the write operation; e.g. an
updateoperation attempts to modify the same document as anotherupdateoperation. See also write conflict.
-
system.profile.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 the FAQ on when operations yield.
-
system.profile.locks¶ New in version 3.0.0:
locksreplaces thelockStatsfield.The
system.profile.locksprovides information for various lock types and lock modes held during the operation.The possible lock types are:
Lock Type Description GlobalRepresents global lock. MMAPV1JournalRepresents MMAPv1 storage engine specific lock to synchronize journal writes; for non-MMAPv1 storage engines, the mode for MMAPV1Journalis empty.DatabaseRepresents database lock. CollectionRepresents collection lock. MetadataRepresents metadata lock. oplogRepresents lock on the oplog. The possible locking modes for the lock types are as follows:
Lock Mode Description RRepresents Shared (S) lock. WRepresents Exclusive (X) lock. rRepresents Intent Shared (IS) lock. wRepresents Intent Exclusive (IX) lock. The returned lock information for the various lock types include:
-
system.profile.locks.acquireCount¶ Number of times the operation acquired the lock in the specified mode.
-
system.profile.locks.acquireWaitCount¶ Number of times the operation had to wait for the
acquireCountlock acquisitions because the locks were held in a conflicting mode.acquireWaitCountis less than or equal toacquireCount.
-
system.profile.locks.timeAcquiringMicros¶ Cumulative time in microseconds that the operation had to wait to acquire the locks.
timeAcquiringMicrosdivided byacquireWaitCountgives an approximate average wait time for the particular lock mode.
-
system.profile.locks.deadlockCount¶ Number of times the operation encountered deadlocks while waiting for lock acquisitions.
For more information on lock modes, see What type of locking does MongoDB use?.
-
-
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
responseLengthcan 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
responseLengthvalue is in a field namedreslen.
-
system.profile.protocol¶ The MongoDB Wire Protocol request message format.
-
system.profile.millis¶ The time in milliseconds from the perspective of the
mongodfrom the beginning of the operation to the end of the operation.
-
system.profile.planSummary¶ New in version 3.4.
A summary of the execution plan.
-
system.profile.execStats¶ Changed in version 3.0.
A document that contains the execution statistics of the query operation. For other operations, the value is an empty document.
The
system.profile.execStatspresents the statistics 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
execStatsis not meant to be exhaustive as the returned fields vary per stage.-
system.profile.execStats.stage¶ New in version 3.0:
stagereplaces thetypefield.The descriptive name for the operation performed as part of the query execution; e.g.
COLLSCANfor a collection scanIXSCANfor scanning index keysFETCHfor retrieving documents
-
system.profile.execStats.inputStages¶ New in version 3.0:
inputStagesreplaces thechildrenfield.An array that contains statistics for the operations that are the input stages 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:0instead of an actual client.
-
system.profile.appName¶ New in version 3.4.
The identifier of the client application which ran the operation. If the operation was run in the MongoDB shell, the appName is always
"MongoDB Shell". If the operation originated from a driver,appNamemay be set to a custom string.
-
system.profile.allUsers¶ An array of authenticated user information (user name and database) for the session. See also Users.
-
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.