MongoDB慢查询

##### 参考 https://docs.mongodb.com/v3.2/administration/analyzing-mongodb-performance/
##### 参考 https://docs.mongodb.com/v3.2/reference/method/db.setProfilingLevel/#db.setProfilingLevel
Database Profiling

MongoDB’s “Profiler” is a database profiling system that can help identify inefficient queries and operations.

Level Setting
0 Off. No profiling
1 On. Only includes “slow” operations
2 On. Includes all operations

Parameter Type Description
level integer Specifies a profiling level, which is either 0 for no profiling, 1 for only slow operations, or 2 for all operations.
slowms integer Optional. Sets the threshold in milliseconds for the profile to consider a query or operation to be slow.

###### 
db.setProfilingLevel(level, slowms)

db.setProfilingLevel(1) 设置时slowms = 100ms 记录所有大于100ms的记录

db.system.profile.find( { millis : { $gt : 100 } } ) #### 查询大于100ms的记录

原文地址:https://www.cnblogs.com/hyming011/p/8251752.html