一、获取、设置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. 【Foreign】哈密顿回路 [MIM]

    哈密顿回路 Time Limit: 15 Sec  Memory Limit: 256 MB Description Input Output Sample Input 4 10 0 3 2 1 3 ...

  2. 【Luogu P3834】可持久化数组(可持久化线段树)

    题目链接 可持久化线段树模板题. 这里总结一下可持久化线段树. 可持久化数据结构就是能恢复历史状态的数据结构,比如可持久化\(Trie\),并查集,平衡树. 可持久化数组是最基础的,这里通过可持久化线 ...

  3. bzoj 1060 贪心

    设根到每个叶子节点的距离为dis,比较容易的看出来,我们需要把这颗树的所有叶子节点的值都变成其中最大的内个,我们设为max,那么对于一颗子树来说,设其中dis值最大的为x,我们需要将这个子树根节点和子 ...

  4. hdu 1399 Starship Hakodate-maru (暴力搜索)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1399 题目大意:找到满足i*i*i+j*(j+1)*(j+2)/6形式且小于等于n的最大值. #inc ...

  5. 【bzoj3227】红黑树

    神TM的红黑树,其实本质上应该还是一种树dp的问题…… 一开始想了一个比较裸的树dp,后来发现还有更强的做法. 每个前端黑节点是看作一个物品,然后这就是很典型的树形dp的问题. 不过可以这么考虑,考虑 ...

  6. 新版谷歌浏览器设置flash插件不提示步骤

    1.先去chrome实验室界面chrome://flags/#enable-ephemeral-flash-permission选择取消Disabled.取消该实验室选项. 2.然后去chrome:/ ...

  7. [译]lambda表达式对 SAM (单个抽象方法类)type的处理方式

    在阅读Venkat Subramaniam的著作<Functional Programming in Java> 之后,方法模式和lambda完美结合让我印象深刻. 这种模式经常用作数据源 ...

  8. Selenium2+python自动化-窗口多标签处理方法总结(转载)

    本篇转自博客:上海-小T 原文地址:https://i.cnblogs.com/EditArticles.aspx?opt=1 我们在用Selenium遇到多个浏览器窗口或单个浏览器多个标签(Tab) ...

  9. rest_frameword框架的基本组件

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

  10. Django之模型ORM

    ORM介绍 ORM概念 对象关系映射(Object Relational Mapping,简称ORM)模式是一种为了解决面向对象与关系数据库存在的互不匹配的现象的技术. 简单的说,ORM是通过使用描述 ...