@@ -52,3 +52,44 @@ the methods listed in the :guilabel:`Alternative Methods` column.
52
52
- :method:`db.collection.findOneAndUpdate()`
53
53
- :method:`db.collection.bulkWrite()`
54
54
55
+ Read Preference Behavior
56
+ ------------------------
57
+
58
+ Read Operations on a Secondary Node
59
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
60
+
61
+ When using ``mongosh`` to connect directly to a :term:`secondary`
62
+ replica set member, you do not have to explicitly enable secondary reads
63
+ with ``rs.secondaryOk()``.
64
+
65
+ You can read from a secondary member if you specify a
66
+ :manual:`read preference </core/read-preference/>` of either:
67
+
68
+ - :readmode:`primaryPreferred`
69
+ - :readmode:`secondary`
70
+ - :readmode:`secondaryPreferred`
71
+
72
+ To specify a read preference, you can use either:
73
+
74
+ - The :urioption:`readPreference` connection string option when
75
+ connecting to the node.
76
+
77
+ - The :method:`Mongo.setReadPref()` method.
78
+
79
+ The legacy ``mongo`` shell required running ``rs.secondaryOk()`` to
80
+ enable secondary reads.
81
+
82
+ ``show`` Helper Methods
83
+ ~~~~~~~~~~~~~~~~~~~~~~~
84
+
85
+ The following ``show`` helper methods always use a read preference of
86
+ ``primaryPreferred``, even when a different read preference has been
87
+ specified for the operation:
88
+
89
+ - ``show dbs``
90
+ - ``show databases``
91
+ - ``show collections``
92
+ - ``show tables``
93
+
94
+ In the legacy ``mongo`` shell, these operations use the specified read
95
+ preference.
0 commit comments