我们正在开发一个应用程序,其中 Java 代码与 Mongo 对话并使用 Spring Data 流式传输结果。我们一直在查看分析器输出,但我并不是 100% 了解它的含义。
https://docs.mongodb.com/manual/reference/database-profiler/
{
"op" : "query",
"ns" : "test.c",
"query" : {
"find" : "c",
"filter" : {
"a" : 1
}
},
"keysExamined" : 2,
"docsExamined" : 2,
"cursorExhausted" : true,
...
"responseLength" : 108,
"millis" : 0,
文档的描述是:
system.profile.millis The time in milliseconds from the perspective of the mongod from the beginning of the operation to the end of the operation.
好的,但是操作是什么?如果我正在执行查询并且我正在拉回 1000 个结果,那么“毫秒”时间是否仅用于查询计划?或者它是否包括它用于拉回结果并将它们发送给驱动程序的整个过程?
这会在流媒体和非流媒体时给出不同的答案吗?
最佳答案
操作就是查询;该查询不返回文档,而是返回一个指向磁盘上文档位置的游标: https://docs.mongodb.com/v3.0/core/cursors/
“millis”结果是MongoDB搜索查询结果(进行索引或集合扫描,找出所有满足查询条件的文档,必要时进行排序)并返回对应的游标给驱动程序所用的时间。
我不确定您所说的“流”是什么意思,但它可能是驱动程序迭代游标以访问查询结果。
关于java - 在分析 Mongo 查询时, "millis"是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38312384/