MongoDB慢查询

本文介绍了MongoDB的性能分析工具——Profiler的使用方法。通过设置不同的级别可以记录所有操作或仅记录慢查询,帮助开发者识别低效的查询和操作。文章详细解释了如何设置Profiler并查询超过指定时间的操作。

##### 参考 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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值