getMore
On this page本页内容
Definition定义
Syntax语法
The command has the following syntax:该命令具有以下语法:
db.runCommand(
{
getMore: <long>,
collection: <string>,
batchSize: <int>,
maxTimeMS: <int>,
comment: <any>
}
)
Command Fields命令字段
The command accepts the following fields:该命令接受以下字段:
getMore | long | |
collection | string | |
batchSize | positive integer | |
maxTimeMS | non-negative integer | maxTimeMS on a getMore for a tailable awaitData cursor is considered the same as maxAwaitTimeMS() . awaitData 游标的getMore 上的maxTimeMS 被认为与maxAwaitTimeMS() 相同。getMore for a tailable cursor on a capped collection with awaitData set to true . awaitData 设置为true 的封顶集合上的可裁剪游标,驱动程序只会在getMore 上设置此值。maxTimeMS , which is the maximum amount of time that the initial operation, and any subsequent getMore operations, can spend cumulatively executing the query. maxTimeMS ,这是初始操作和任何后续getMore 操作累积执行查询所花费的最大时间。awaitData set to true , the following is true: awaitData 设置为true 的可裁剪游标,以下为true :
db.killOp() . db.killOp() 相同的机制终止超过指定时间限制的操作。
|
comment | any |
|
Output输出
The command returns a document that contains the cursor information as well as the next batch.该命令返回一个文档,该文档包含游标信息以及下一批。
For example, running 例如,在分片集群上的getMore
on a cursor created by a find
operation on a sharded cluster returns a document similar to the one below:find
操作创建的游标上运行getMore
会返回一个类似于下面的文档:
{
"cursor" : {
"id" : NumberLong("678960441858272731"),
"ns" : "test.contacts",
"nextBatch" : [
{
"_id" : ObjectId("5e8e501e1a32d227f9085857"),
"zipcode" : "220000"
}
],
"partialResultsReturned" : true,
"postBatchResumeToken": "< Resume Token >"
},
"ok" : 1,
"operationTime" : Timestamp(1586385239, 2),
"$clusterTime" : {
"clusterTime" : Timestamp(1586385239, 2),
"signature" : {
"hash" : BinData(0,"lLjejeW6AQGReR9x1PD8xU+tP+A="),
"keyId" : NumberLong("6813467763969884181")
}
}
}
cursor | nextBatch of documents.nextBatch 。find (or subsequent getMore commands) returns partial results because the queried shard(s) aren't available, the find output includes a partialResultsReturned indicator field. find (或后续的getMore 命令)由于查询的分片不可用而返回部分结果,则find输出包括一个partialResultsReturned 指示符字段。find command, but one or more shards become unavailable for subsequent getMore commands, only the getMore commands that run while the shards aren't available include partialResultsReturned in their output.find 命令,但一个或多个分片不可用于后续的getMore 命令,则只有在分片不可用时运行的getMore 命令在其输出中包含partialResultsReturned 。postBatchResumeToken field can be used with the $changeStream pipeline to start or resume a change stream from this point. postBatchResumeToken 字段可以与$changeStream 管道一起使用,以从此点开始或恢复更改流。 |
"ok" | 1 ) or failed (0 ).1 )还是失败(0 )。 |
In addition to these fields, the 除了这些字段之外,db.runCommand()
response includes the following information for replica sets and sharded clusters:db.runCommand()
响应还包括复制集和分片集群的以下信息:
$clusterTime
operationTime
See db.runCommand() Response for details.有关详细信息,请参阅db.runCommand()
响应。
Behavior行为
Access Control访问控制
If authentication is turned on, you can only run 如果启用了身份验证,则只能对创建的游标运行getMore
against cursors you created.getMore
。
Sessions会话
For cursors created inside a session, you cannot call 对于在会话内创建的游标,不能在会话外调用getMore
outside the session.getMore
。
Similarly, for cursors created outside of a session, you cannot call 类似地,对于在会话之外创建的游标,不能在会话内部调用getMore
inside a session.getMore
。
Transactions事务
Slow Queries慢速查询
Starting in MongoDB 5.1, when a 从MongoDB 5.1开始,当getMore
command is logged as a slow query, the queryHash and planCacheKey fields are added to the slow query log message and the profiler log message.getMore
命令作为慢速查询记录时,queryHash
和planCacheKey
字段将添加到慢速查询日志消息和探查器日志消息中。