Docs Menu

Docs HomeMongoDB Manual

Hedged Read Option

Starting in MongoDB 4.4 for sharded clusters, you can specify the use of hedged reads for non-primary read preferences.

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.

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.

To use hedged reads, enable the hedge read option for non-primary read preferences. Read preference nearest specifies hedged read by default.

  • When using the drivers, refer to the drivers' read preference API.

  • When using mongosh, you can use the helper methods cursor.readPref() and Mongo.setReadPref()

For more information on hedged reads, see Hedged Reads.

For details on member selection for hedged reads, see Read Preference and Shards.

The command serverStatus and its corresponding mongosh method db.serverStatus() return hedgingMetrics

←  Read Preference maxStalenessSecondsRead Preference Use Cases →
Give Feedback
© 2022 MongoDB, Inc.

About

  • Careers
  • Investor Relations
  • Legal Notices
  • Privacy Notices
  • Security Information
  • Trust Center
© 2022 MongoDB, Inc.