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

查看:27
本文介绍了如何在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).您可以使用 调整慢速操作的阈值(默认为 100 毫秒)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天全站免登陆