我们正在开发一个应用程序,其中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 从操作开始到操作结束的mongod视角的时间(以毫秒为单位)。
好的,但是什么操作?如果我正在执行查询并且我将1000结果拉回来,那么" millis"时间只针对查询计划?或者它是否包括它将结果拉回并将它们发送给驱动程序的整个过程?
在流式传输与非流式传输时,这会给出不同的答案吗?
答案 0 :(得分:0)
The operation is the query; the query does not return documents, but instead returns a cursor that points to the locations of the documents on disk: https://docs.mongodb.com/v3.0/core/cursors/
The "millis" result is the time it takes MongoDB to search for the query results (perform index or collection scan, identify all documents that meet the query criteria and perform sorts if necessary) and return the return the corresponding cursor to the driver.
I'm not certain with what you mean by "streaming", but it could be the driver iterating over the cursor to access the results of the query.