Hi everyone,
I have a question with regards to using a compound index as a shard key:
I understand that you can specify each prefix up to the entire shard key & still get a targeted query
like so:
-
If I have a shard key like so:
{"sku": 1, "type": 1, "name: 1"}
-
The following will be targeted queries:
db.products.find({ "sku": ....}) db.products.find({ "sku": ...., "type": ...}) db.products.find({ "sku": ...., "type": ..., "name": ...})
-
…and the following are not targeted queries:
db.products.find({ "type": ....}) db.products.find({ "name": ....})
This is all quite simple to understand, but what if I have a query such as the one below:
db.products.find({ "name": ...., "type": ...., "sku": ....})
Does the prefix/order matter in this case?
Thanks in advance to anyone who can help!