mongodb:如何查看聚合命令的执行时间? [英] mongodb: how can I see the execution time for the aggregate command?

查看:562
本文介绍了mongodb:如何查看聚合命令的执行时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在mongo shell中执行follow mongodb命令

I execute the follow mongodb command in mongo shell

db.coll.aggregate(...)

,我看到结果列表.但是有可能看到查询 执行时间处理时间?聚合查询的解释方法有什么等效功能.

and i see the list of result. but is it possible to see the query execution time? Is there any equivalent function for explain method for aggregation queries.

推荐答案

我将写一个答案来更好地解释这一点.

I will write an answer to explain this better.

基本上,聚合框架还没有explain()功能: https://jira. mongodb.org/browse/SERVER-4504

Basically there is no explain() functionality for the aggregation framework yet: https://jira.mongodb.org/browse/SERVER-4504

但是,有一种方法可以衡量客户端,但不能没有缺点:

However there is a way to measure client side but not without its downsides:

  • 您没有测量数据库
  • 您正在评估应用程序
  • 关于各部分之间的内在信息太多,以至于无法准确读取,也就是说,您不能说MongoDB服务器通过序列化,发送来的文档结果花费了0.04毫秒的时间.线,由应用反序列化,然后存储到哈希中,使您可以从总数中减去该总和以获得汇总基准.

尽管如此,通过在与mongos/mongod相同的服务器上的MongoDB控制台中进行操作,您也许可以得到稍微准确的结果.这将产生很少的中间值,仍然太多,但足以获得您可以大致信任的读数.因此,您可以在该位置使用@Zagorulkin的答案.

However that being said, you might be able to get a slightly accurate result by doing it in MongoDB console on the same server as the mongos / mongod. This will create very little in betweens, still too many but enough to maybe get a reading you could roughly trust. As such you could use @Zagorulkin's answer in that position.

这篇关于mongodb:如何查看聚合命令的执行时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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