mongodb 慢查詢日志


指定閾值慢查詢 ,超過1000毫秒的查詢被記錄
db.setProfilingLevel(1, { slowms: 1000 })

//關掉慢查詢日志
db.setProfilingLevel(0)

///刪除日志集合
db.system.profile.drop()
 
// 查詢慢查詢級別和其它信息
db.getProfilingStatus()
 
// 僅返回慢查詢級別
db.getProfilingLevel()
 
// 查詢最近的10個慢查詢日志
db.system.profile.find({"millis":{$gte:4000}}).limit(50).sort( { ts : -1 } ).pretty()
 
// 查詢 低於 5毫秒的日志
db.system.profile.find( { millis : { $gt : 5 } } ).pretty()
 
// 查詢時間從 2021-03-15 3點整到 2021-03-17 3點40分之間的日志
db.system.profile.find({
  ts : {
    $gt: new ISODate("2021-03-15T03:00:00Z"),
    $lt: new ISODate("2021-03-17T03:40:00Z")
  }
}).pretty()

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM