By default, all read operations (for example, database queries) are directed to the primary. On a busy website, however, this might not yield optimal performance, especially where the replica set is geographically dispersed. Accordingly, it's possible to specify a read preference when initiating a query.
In the case of a pymongo.mongo_client.MongoClient instance, simple read preferences are expressed using the following values in conjunction with the readPreference **kwarg parameter:
Preference | Notes |
primary | All read requests are directed to the primary. This is the default. |
primaryPreferred | If this preference is set, requests are directed to the primary. If the primary is unavailable, however, the request falls back to one of the secondaries. |
secondary | This preference causes requests to be directed to any secondary replica set member, but not to the primary. |
secondaryPreferred... |