MongoDB Applied Design Patterns by Rick Copeland

MongoDB Applied Design Patterns by Rick Copeland

Author:Rick Copeland
Language: eng
Format: epub, azw3, pdf
Tags: COMPUTERS / Data Modeling & Design
ISBN: 9781449340032
Publisher: O’Reilly Media
Published: 2013-03-03T16:00:00+00:00


While sharding is the best way to scale operations, some data sets make it impossible to partition data so that mongos can route queries to specific shards. In these situations, mongos sends the query to all shards and then combines the results before returning to the client.

In these situations, you can gain some additional read performance by allowing mongos to read from the secondary mongod instances in a replica set by configuring the read preference in the client. Read preference is configurable on a per-connection or per-operation basis. In pymongo, this is set using the read_preference keyword argument.

The pymongo.SECONDARY argument in the following example permits reads from the secondary (as well as a primary) for the entire connection:



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.