Assuming that your sharded cluster has been implemented as a series of replica sets, one per shard, writing data to a sharded cluster is no different than writing data to a replica set. Here are some considerations for insert, update, and delete operations:
- Insert: When performing an insert operation, the sharded cluster balancer decides into which chunk to place the document, based on the shard key value of the document to be added.
- Update: In the case of an update, bear in mind that you'll need to supply a query document in addition to the update document. Just as with a read operation, if you include the shard key in the query document, updates show improved performance. If you set the upsert argument to True, you must include a shard key in the update-document in order for the sharded cluster balancer to correctly place the inserted document.
- Delete: Again, as with an update, you need to supply a query document. Include the shard key...