zoukankan      html  css  js  c++  java
  • 关于profile集合

    profile集合是mongodb的慢操作日志
    > db.getProfilingStatus()
    { "was" : 0, "slowms" : 100, "sampleRate" : 1 }

    可以通过getProfilingStatus来查看当前profile设置

    profile分为3个级别

    0:表明profile是关闭的,mongodb不会记录任何操作
    1:配合slowms做预值,mongodb会记录所有超过slowms的操作
    2:mongodb会记录任何操作
    设置profile级别
    > db.setProfilingLevel(2)
    { "was" : 0, "slowms" : 100, "sampleRate" : 1, "ok" : 1 }
    得到profile级别
    > db.getProfilingLevel()
    2
    > db.system.profile.find().sort({$natural:-1}).limit(2)
    { "op" : "query", "ns" : "test.system.profile", "command" : { "find" : "system.profile", "filter" : { }, "limit" : 10, "singleBatch" : false, "sort" : { "$natural" : -1 }, "$db" : "test" }, "keysExamined" : 0, "docsExamined" : 10, "cursorExhausted" : true, "numYield" : 0, "nreturned" : 10, "locks" : { "Global" : { "acquireCount" : { "r" : NumberLong(1) } }, "Database" : { "acquireCount" : { "r" : NumberLong(1) } }, "Collection" : { "acquireCount" : { "r" : NumberLong(1) } } }, "responseLength" : 5140, "protocol" : "op_msg", "millis" : 0, "planSummary" : "COLLSCAN", "execStats" : { "stage" : "LIMIT", "nReturned" : 10, "executionTimeMillisEstimate" : 0, "works" : 12, "advanced" : 10, "needTime" : 1, "needYield" : 0, "saveState" : 0, "restoreState" : 0, "isEOF" : 1, "invalidates" : 0, "limitAmount" : 10, "inputStage" : { "stage" : "COLLSCAN", "nReturned" : 10, "executionTimeMillisEstimate" : 0, "works" : 11, "advanced" : 10, "needTime" : 1, "needYield" : 0, "saveState" : 0, "restoreState" : 0, "isEOF" : 0, "invalidates" : 0, "direction" : "backward", "docsExamined" : 10 } }, "ts" : ISODate("2018-08-11T23:37:03.517Z"), "client" : "127.0.0.1", "appName" : "MongoDB Shell", "allUsers" : [ ], "user" : "" }
    { "op" : "query", "ns" : "test.system.profile", "command" : { "find" : "system.profile", "filter" : { }, "$db" : "test" }, "cursorid" : 63845545503, "keysExamined" : 0, "docsExamined" : 101, "numYield" : 0, "nreturned" : 101, "locks" : { "Global" : { "acquireCount" : { "r" : NumberLong(1) } }, "Database" : { "acquireCount" : { "r" : NumberLong(1) } }, "Collection" : { "acquireCount" : { "r" : NumberLong(1) } } }, "responseLength" : 44741, "protocol" : "op_msg", "millis" : 0, "planSummary" : "COLLSCAN", "execStats" : { "stage" : "COLLSCAN", "nReturned" : 101, "executionTimeMillisEstimate" : 0, "works" : 102, "advanced" : 101, "needTime" : 1, "needYield" : 0, "saveState" : 1, "restoreState" : 0, "isEOF" : 0, "invalidates" : 0, "direction" : "forward", "docsExamined" : 101 }, "ts" : ISODate("2018-08-11T23:35:25.260Z"), "client" : "127.0.0.1", "appName" : "MongoDB Shell", "allUsers" : [ ], "user" : "" }
    可以看到操作记录被记录在system.profile集合中,$natural是自然排序,-1表示操作的越晚,排在越前面
    op:操作类型,当前是query
    ns:是查询的命令空间,命名格式是数据库名字+集合名字
    query:查询的字符串
    ...
    profile适合应用测试,或者刚上线的时候,数据量太多需要加索引,加大小,每次启动都会占用一些性能
  • 相关阅读:
    2月份热门的 24 个 jQuery 插件
    走近求伯君1 求伯君,1964年11月26日出生于浙江新昌县。
    转CSDN,13原则
    SQL Server数据库如何正确加密?
    Zend Studio提供zend studio教程、zend studio下载等相关资源的公益性站点。 订阅
    高端人才必看,生意人必读
    有速度才有效率,支持Google gear离线的网站和应用
    2009.08.20总结与微软中国开发部经理段老师的通话无锡德立解决方案
    从SOA、SaaS到博科自主配置平台
    MySQL 1045错误的解决方法
  • 原文地址:https://www.cnblogs.com/wzndkj/p/9461934.html
Copyright © 2011-2022 走看看