251224-MongoDB-SlowQuery慢查询定位
Created At :
1. 直接读 system.profile(最常用)
打开数据库级别的 Profiling
1 2
| use vatti db.setProfilingLevel(1, 500); -- 记录 >50 ms 的操作
|
2. 可看到慢查询字段
1 2 3 4
| db.system.profile.find({millis:{$gte:500}}) .sort({ts:-1}) .limit(1000) .pretty();
|