一、获取、设置profile(profile用collection存储数据)
db.setProfilingLevel(level)  默认为100毫秒  
db.setProfilingLevel(level,slowms)


On. Includes all operations  (包含所有操作)

二、查看profile数据
db.system.profile.find() //查看所有


三、profile数据示例
{
    "op" : "insert",
    "ns" : "test.orders",
    "query" : {
       "_id" : 1,
       "cust_id" : "A123",
       "amount" : 500,
       "status" : "A"
    },
    "ninserted" : 1,
    "keyUpdates" : 0,
    "writeConflicts" : 0,
    "numYield" : 0,
    "locks" : {
          "Global" : {
             "acquireCount" : {
                "w" : NumberLong(1)
             }
          },
          "MMAPV1Journal" : {
             "acquireCount" : {
                "w" : NumberLong(2)
             }
          },
          "Database" : {
             "acquireCount" : {
                "w" : NumberLong(1)
             }
          },
          "Collection" : {
             "acquireCount" : {
                "W" : NumberLong(1)
             }
          }
       },
    ,
    "millis" : 0,
    "execStats" : {
    },
    "ts" : ISODate("2012-12-10T19:31:28.977Z"),
    "client" : "127.0.0.1",
    "allUsers" : [ ],
    "user" : ""
}


四、profile说明
1、system.profile.op
  • insert
  • query
  • update
  • remove
  • getmore
  • command

2、system.profile.ns

   命名空间:数据库名.collection名
3、system.profile.query
   查询条件
4、system.profile.command
   op为command时使用
5、system.profile.updateobj
   op为update时使用
6、system.profile.ntoreturn
   期望返回数量,query语句期望返回的数量,如limit(40)
7、system.profile.nreturned
   实际返回的数量
8、system.profile.ntoskip
   skip()方法跳过的记录数
9、system.profile.nscanned
   扫描次数,当扫描次数大于返回的数量(ntoreturn),考虑使用索引
   
nscanned和nscannedObjects区别:
   1、nscanned:根据索引扫描文档,扫描的可能返回实际返回的数量
   2、nscannedObjects:扫描完整的文档,扫描实际返回的数据
    http://stackoverflow.com/questions/13910097/explain-in-mongodb-differences-between-nscanned-and-nscannedobjects
10、system.profile.moved
   表示update操作移动的数据数量
11、system.profile.scanAndOrder
    布尔值,当为true时,表明排序未使用到索引,只有true时该字段才显示
12、system.profile.ndeleted
    删除操作影响的数据数量
13、system.profile.ninserted
    写入操作写入的数据数量
14、system.profile.nModified
    修改操作影响的数据数量
15、system.profile.responseLength
    返回的数据长度,单位为字节
16、system.profile.millis
    操作执行时间
17、system.profile.execStats
    统计信息,一般op为query有
18、system.profile.ts
    操作执行时间
19、system.profile.client
         客户端主机名或ip
20、system.profile.locks.acquireCount
        特定模式下获取锁的操作次数
14、system.profile.locks

The possible lock types are:

  • Global represents global lock.
  • MMAPV1Journal represents MMAPv1 storage engine specific lock to synchronize journal writes; for non-MMAPv1 storage engines, the mode for MMAPV1Journal is empty.
  • Database represents database lock.
  • Collection represents collection lock.
  • Metadata represents metadata lock.
  • oplog represents lock on the oplog.

The possible locking modes for the lock types are as follows:

  • R represents Shared (S) lock.
  • W represents Exclusive (X) lock.
  • r represents Intent Shared (IS) lock.
  • w represents Intent Exclusive (IX) lock.

    "locks" : {
        "Global" : {
          "acquireCount" : {
            "w" : NumberLong(1)
          }
        },
        "MMAPV1Journal" : {
          "acquireCount" : {
            "w" : NumberLong(1)
          }
        },
        "Database" : {
          "acquireCount" : {
            "W" : NumberLong(1)
          }
        }
      },

mongodb_profier的更多相关文章

随机推荐

  1. 【BZOJ3700】发展城市 [LCA][RMQ]

    发展城市 Time Limit: 20 Sec  Memory Limit: 512 MB[Submit][Status][Discuss] Description 众所周知,Hzwer学长是一名高富 ...

  2. DotNet 学习笔记 应用状态管理

    Application State Options --------------------------------------------------------------------- *Htt ...

  3. centOS 7 部署samba

    部署samba **每个用户有自己的目录,可以浏览内容,也可以删除** 清空防火墙规则 [root@bogon ~]# iptables -F 安装samba [root@bogon ~]# yum ...

  4. rest_frameword框架的基本组件

    序列化 序列化:转化数据和校验数据(提交数据时校验数据类型) 开发我们的Web API的第一件事是为我们的Web API提供一种将代码片段实例序列化和反序列化为诸如json之类的表示形式的方式.我们可 ...

  5. hdu 5185(动态规划)

    Equation Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Su ...

  6. [scrapy] PIL老是出错,换成pillow解决问题

    使用scrapy下载图片的时候,用PIL老是下载不成功 出现如下错误: IOError: encoder jpeg not available 据说是安装PIL之前缺少一些相关的包 freetype ...

  7. CF 990A. Commentary Boxes【数学/模拟】

    [链接]:CF [题意]:对于一个数n,每次加一的代价是a,每次减一的代价是b,求被m整除时的最小代价. [分析]:分情况讨论,自己多举几个栗子. [代码]: #include<cstdio&g ...

  8. Educational Codeforces Round 30 B【前缀和+思维/经典原题】

    B. Balanced Substring time limit per test 1 second memory limit per test 256 megabytes input standar ...

  9. Html5+CSS

    1. 内联样式是为元素添加样式的最简单有效的方式,但是更易于维护的方式是使用层叠样式表CSS(Cascading Style Sheets). <style>  选择器 {属性名称: 属性 ...

  10. luogu P3919 【模板】可持久化数组(可持久化线段树/平衡树)

    As you see // luogu-judger-enable-o2 #include<cstdio> #include<cstring> #include<algo ...