MongoDB 为聚合查询获取 executionStats [英] MongoDB get executionStats for aggregate query
问题描述
我正在寻找一种方法来检索聚合的 executionStats
.
I am looking for a way to retrieve the executionStats
for aggregations.
使用 find() 时,我可以使用 explain.示例输出:
When using find(), I can retrieve them easily by using explain. Example output:
"executionStats": {
"nReturned": 332505,
"executionTimeMillis": 1349,
"totalKeysExamined": 332505,
"totalDocsExamined": 332505,
...
但是当使用 启用了解释的聚合它不会返回上面显示的统计信息.
But when using aggregations with explain enabled it won't return the stats shown above.
这个 和 this 是相关的,但没有给出可行的解决方案.因为这可能在此期间发生了变化,所以我打开了这个问题.
This and this is related but there is no viable solution given. Because this might have changed in the meantime, I opened this question.
有没有什么办法可以在不测量客户端统计数据的情况下做到这一点?
Is there any way this can be done without measuring the stats on the client side?
推荐答案
目前(MongoDB 3.2)聚合不支持 executionStats,在聚合中使用解释选项可以获得一些与查询相关的数据,但其中没有 executionStats.它已被提议,您可以在此处查看其状态
Currently(MongoDB 3.2) aggregation does not support executionStats, with explain option in aggreagation you get some data related to query but there is no executionStats in it. It is proposed and you can check its status here
https://jira.mongodb.org/browse/SERVER-19758
如果您想尽快实施此问题,请对该问题进行投票.
Please upvote the issue if you want to implement this soon.
这篇关于MongoDB 为聚合查询获取 executionStats的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!