Picking a good shard key

Question:

Looking at the video “Picking a good shard key”. Can we have more than 1 shard key on a collection? so we can expand the possibility of having more targeted queires.

Thank you.

Hello @Bernardo_Godinez, no you cannot have more than one shard key. But, you can have a shard key with multiple fields. The shard key must be an index or can be a compound index where the shard key is a prefix of the index.

Also see this topic on Refine a Shard Key; this is a new feature with MongoDB v4.4. This allows add a suffix field(s) to the existing key to create the new shard key.

2 Likes

Hi @Bernardo_Godinez,

I hope the above response of @Prasad_Saya satisfies your concerns regarding this question.

Feel free to reach out if you have any other question.

Regards
Kushagra

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.