如何在mongodb中查找不使用索引或速度较慢的查询 [英] How to find queries not using indexes or slow in mongodb

查看:168
本文介绍了如何在mongodb中查找不使用索引或速度较慢的查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在mongodb中查找未使用索引或查询速度慢的查询?在MySQL中,可以在配置文件中进行以下设置:

is there a way to find queries in mongodb that are not using Indexes or are SLOW? In MySQL that is possible with the following settings inside configuration file:

log-queries-not-using-indexes = 1
log_slow_queries = /tmp/slowmysql.log

推荐答案

MongoDB中的等效方法是使用

The equivalent approach in MongoDB would be to use the query profiler to track and diagnose slow queries.

为数据库启用概要分析后,会将慢速操作写入限制为system.profile的集合(默认大小为1Mb).您可以使用 slowms参数.

With profiling enabled for a database, slow operations are written to the system.profile capped collection (which by default is 1Mb in size). You can adjust the threshold for slow operations (by default 100ms) using the slowms parameter.

这篇关于如何在mongodb中查找不使用索引或速度较慢的查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆