March 2019
Intermediate to advanced
394 pages
11h 4m
English
If our query includes the shard key or a prefix of the shard key, mongos will perform a targeted operation, only querying the shards that hold the keys that we are looking for.
For example, with a composite shard key of {_id, email, address} on our User collection, we can have a targeted operation with any of the following queries:
> db.User.find({_id: 1})> db.User.find({_id: 1, email: 'alex@packt.com'})> db.User.find({_id: 1, email: 'janluc@packt.com', address: 'Linwood Dunn'})
These queries consist of either a prefix (as is the case with the first two) or the complete shard key.
On the other hand, a query on {email, address} or {address} will not be able to target the right shards, resulting in a broadcast operation. A broadcast operation ...
Read now
Unlock full access