I am having collection ("links") with listed fields:
collection-name: "links"
1) url
2) title
3) score
4) description
5) ratings (embedded_many)
and having index on "url", "title", "score"
because I need to find links based on these ("url", "title", "score") fields. query like : matching "url", "title" and "score" equal, gte, lte.
I would like to apply sharing on links collection.
Please guide me what should be the sharing-key and why ?
1) Cardinality for each field
url: 50,40,059
title: 50,10,105
score: 50,40,059
2) If null values exists on those fields
title: could have null value.
3) Is those fields changing?
only 'score' is changing after period of time.
Best Answer
From what you share the url seems the best candidate for shard key. Has good cardinality, its not monotonically increased (since is url), does not modified and don't contain null values.
Additionally your reads contain the url will directed to only one shard, which is the best scenario.
We can discuss that further on chat after Xmas, because sharding isn't always easy task.
Antonis