MongoDB CPU 占用率高

连接数据库

示例如下 请根据自己的数据库ip和监听的端口号输入

mongo --host 192.168.3.81 --port 27017

切换数据库

use admin
db.auth("yourusername","yourpassword")
use yourdbname;

记录查询操作详情

db.setProfilingLevel(2);//记录所有的操作
db.setProfilingLevel(0);//不记录任何操作
db.setProfilingLevel(1,50);//记录大于50毫秒的操作

显示 

{ "was" : 1, "slowms" : 50, "ok" : 1 }

即为成功

查看profile

db.getCollection('system.profile').find({})

分析 profile中mills较大的 command

假设分析发现查询  user 集合 的  username  和  userage 的  mills较大。

创建索引user集合 username 和 userage 的索引

db.user.createIndex({"username":1,"userage":1})

查看索引

db.user.getIndexes()

删除所有的索引

db.user.dropIndexes()

清空 profile

db.system.profile.drop()

Since this Handler is declared as an inner class, it may prevent the outer class from being garbage collected. If the Handler is using a Looper or MessageQueue for a thread other than the main thread, then there is no issue. If the Handler is using the Looper or MessageQueue of the main thread, you need to fix your Handler declaration, as follows: Declare the Handler as a static class; In the outer class, instantiate a WeakReference to the outer class and pass this object to your Handler when you instantiate the Handler; Make all references to members of the outer class using the WeakReference object.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值