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()