发布于 2015-09-14 15:10:47 | 114 次阅读 | 评论: 0 | 来源: 网络整理

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 分析数据库操作的性能 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.

注解

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:

{
    "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

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.ts

The timestamp of the 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. See Query Specification Documents for more information on these documents, and 元查询算符快参 for more information.

system.profile.command

The command operation.

system.profile.updateobj

The update document passed in during an update operation.

system.profile.cursorid

The ID of the cursor accessed by a getmore operation.

system.profile.ntoreturn

在 2.2 版更改: In 2.0, MongoDB includes this field for query and command operations. In 2.2, this information MongoDB also includes this field for getmore operations.

The number of documents the operation specified to return. For example, the profile command would return one document (a results document) so the ntoreturn value would be 1. The limit(5) 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 find() command with no limit specified.

system.profile.ntoskip

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 than nreturned, the database is scanning many objects to find the target objects. Consider creating an index to improve this.

system.profile.moved

If moved has a value of true indicates that the update operation moved one or more documents to a new location on disk. These operations take more time than in-place updates, and typically occur when documents grow as a result of document growth.

system.profile.nmoved

2.2 新版功能.

The number of documents moved on disk by the operation.

system.profile.nupdated

2.2 新版功能.

The number of documents updated by the operation.

system.profile.keyUpdates

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

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

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 lock
  • W - global write lock
  • r - database-specific read lock
  • w - 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, then 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 a the result document for a query operation, you can use any of the following:

system.profile.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.

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 is 0.0.0.0:0 instead of an actual client.

system.profile.user

The authenticated user who ran the operation.

最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务