mongodb第十七篇~mongo慢语句的基本

简介:今天来聊聊最基本的
关注
 profile
         1开启
          db.setProfilingLevel(1,200) 1代表记录慢日志 200代表ms数
          db.getProfilingLevel() 查看profile等级
          2 具体介绍
           为什么要介绍profile,因为3.0.6的慢日志记录在shard.log中,是以profile方式记录的
          3 具体参数简介
           op 具体的操作
           ns 具体的空间名
           query 具体的查询语句
           ntoreturn 期望返回的值
           nscanned 扫描的行数
           responseLength 返回结果集的大小单位byte 该值如果过大,则需考虑limit()等方式减少输出结果
           writeConflicts 写冲突发生的次数
           nreturned 实际返回的行数
           execStats 包含了是否应用到索引等行为
           ts 该操作执行时的时间

           4 常见命令

          db.system.profile.find().limit(10).sort( { ts : -1 } ).pretty() 查询最近的10条记录
          db.system.profile.find({ns:'nspace'},{"ts": {"$gt":ISODate("time1","$lt":ISODate("time2") } }) 查询指定时间段和指定库的profile

猜你喜欢

转载自www.cnblogs.com/danhuangpai/p/9145070.html