Hedged Read Option对冲突取选项
Starting in MongoDB 4.4 for sharded clusters, you can specify the use of hedged reads for non-从MongoDB 4.4中针对分片集群开始,您可以为非primary
read preferences.primary
读取偏好指定对冲读取的使用。
With hedged reads, the 通过对冲读取,mongos
instances can route read operations to two replica set members per each queried shard and return results from the first respondent per shard.mongos
实例可以将读取操作路由到每个查询的分片的两个副本集成员,并返回每个分片的第一个响应者的结果。
Hedged reads are supported for the following operations:对冲读取支持以下操作:
To specify hedged read for a read preference, MongoDB 4.4 introduces the hedged read option for read preferences.为了为读取偏好指定对冲读取,MongoDB 4.4为读取偏好引入了对冲读取选项。
Enable Hedged Reads启用对冲读取
To use hedged reads, enable the hedge read option for non-要使用对冲读取,请为非primary
read preferences. primary
读取首选项启用对冲读取选项。Read preference 读取首选项nearest
specifies hedged read by default.nearest
指定默认情况下的对冲读取。
When using the drivers, refer to the drivers' read preference API.使用驱动程序时,请参阅驱动程序的读取首选项API。When using使用mongosh
, you can use the helper methodscursor.readPref()
andMongo.setReadPref()
.mongosh
时,可以使用助手方法cursor.readPref()
和Mongo.setReadPref()
。
Additional Information附加信息
For more information on hedged reads, see Hedged Reads.有关对冲读取的更多信息,请参阅对冲读取。
Member Selection with Hedged Reads对冲读取的会员选择
For details on member selection for hedged reads, see Read Preference and Shards.有关对冲读取的成员选择的详细信息,请参阅读取偏好和分片。
Hedged Reads Diagnostics套期保值读取诊断
The command 命令serverStatus
and its corresponding mongosh
method db.serverStatus()
return hedgingMetrics
.serverStatus
及其相应的mongosh
方法db.serverStatus()
返回hedgingMetrics
。