Mongodb 实践

Mongodb 慢查询分析

db.setProfilingLevel(1)
db.setProfilingLevel(1,1000)
db.getProfilingStatus()

查看记录下来的耗时语句
db.system.profile.find()

其中,"ts" : ISODate("2018-03-28T01:53:10.779Z")为执行命令时间:
db.system.profile.find().sort({ts:-1})

通过explain()查看index使用情况
db.getCollection('collection_name').find({"insertTime" : {"$gte":ISODate("2018-02-06T05:47:00.267Z"), "$lte":ISODate("2018-03-06T05:47:00.267Z")}}).explain()

猜你喜欢

转载自www.cnblogs.com/sunzhuli/p/9695225.html