MongoDB Sharding : What should be the Sharding key if we want to find records with more than one field












0















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.









share|improve this question
















bumped to the homepage by Community 28 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
















  • Its not that easy to guide you and with so few info provided. Calculate and share 1) Cardinality for each field 2) If null values exists on those fields 3) Is those fields changing? 4) Your current write/read ratio

    – Antonios
    Dec 24 '14 at 9:59













  • have updated question, please shed some light on this.

    – Raghvendra Parashar
    Dec 24 '14 at 19:31
















0















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.









share|improve this question
















bumped to the homepage by Community 28 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
















  • Its not that easy to guide you and with so few info provided. Calculate and share 1) Cardinality for each field 2) If null values exists on those fields 3) Is those fields changing? 4) Your current write/read ratio

    – Antonios
    Dec 24 '14 at 9:59













  • have updated question, please shed some light on this.

    – Raghvendra Parashar
    Dec 24 '14 at 19:31














0












0








0








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.









share|improve this question
















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.






mongodb sharding






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 24 '14 at 19:30







Raghvendra Parashar

















asked Dec 22 '14 at 11:33









Raghvendra ParasharRaghvendra Parashar

1012




1012





bumped to the homepage by Community 28 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community 28 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • Its not that easy to guide you and with so few info provided. Calculate and share 1) Cardinality for each field 2) If null values exists on those fields 3) Is those fields changing? 4) Your current write/read ratio

    – Antonios
    Dec 24 '14 at 9:59













  • have updated question, please shed some light on this.

    – Raghvendra Parashar
    Dec 24 '14 at 19:31



















  • Its not that easy to guide you and with so few info provided. Calculate and share 1) Cardinality for each field 2) If null values exists on those fields 3) Is those fields changing? 4) Your current write/read ratio

    – Antonios
    Dec 24 '14 at 9:59













  • have updated question, please shed some light on this.

    – Raghvendra Parashar
    Dec 24 '14 at 19:31

















Its not that easy to guide you and with so few info provided. Calculate and share 1) Cardinality for each field 2) If null values exists on those fields 3) Is those fields changing? 4) Your current write/read ratio

– Antonios
Dec 24 '14 at 9:59







Its not that easy to guide you and with so few info provided. Calculate and share 1) Cardinality for each field 2) If null values exists on those fields 3) Is those fields changing? 4) Your current write/read ratio

– Antonios
Dec 24 '14 at 9:59















have updated question, please shed some light on this.

– Raghvendra Parashar
Dec 24 '14 at 19:31





have updated question, please shed some light on this.

– Raghvendra Parashar
Dec 24 '14 at 19:31










1 Answer
1






active

oldest

votes


















0














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






share|improve this answer
























  • Thanks for your response. But if I will have 'url' for shared-key then how can I query for title-match and score-with-limit(less-than, greater-than-equal)

    – Raghvendra Parashar
    Dec 25 '14 at 6:07













  • If the url field can limit the result set to a small number for example 100 records it should be fine.

    – Antonios
    Dec 25 '14 at 10:40











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "182"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f86766%2fmongodb-sharding-what-should-be-the-sharding-key-if-we-want-to-find-records-wi%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














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






share|improve this answer
























  • Thanks for your response. But if I will have 'url' for shared-key then how can I query for title-match and score-with-limit(less-than, greater-than-equal)

    – Raghvendra Parashar
    Dec 25 '14 at 6:07













  • If the url field can limit the result set to a small number for example 100 records it should be fine.

    – Antonios
    Dec 25 '14 at 10:40
















0














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






share|improve this answer
























  • Thanks for your response. But if I will have 'url' for shared-key then how can I query for title-match and score-with-limit(less-than, greater-than-equal)

    – Raghvendra Parashar
    Dec 25 '14 at 6:07













  • If the url field can limit the result set to a small number for example 100 records it should be fine.

    – Antonios
    Dec 25 '14 at 10:40














0












0








0







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






share|improve this 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







share|improve this answer












share|improve this answer



share|improve this answer










answered Dec 24 '14 at 22:40









AntoniosAntonios

1,057413




1,057413













  • Thanks for your response. But if I will have 'url' for shared-key then how can I query for title-match and score-with-limit(less-than, greater-than-equal)

    – Raghvendra Parashar
    Dec 25 '14 at 6:07













  • If the url field can limit the result set to a small number for example 100 records it should be fine.

    – Antonios
    Dec 25 '14 at 10:40



















  • Thanks for your response. But if I will have 'url' for shared-key then how can I query for title-match and score-with-limit(less-than, greater-than-equal)

    – Raghvendra Parashar
    Dec 25 '14 at 6:07













  • If the url field can limit the result set to a small number for example 100 records it should be fine.

    – Antonios
    Dec 25 '14 at 10:40

















Thanks for your response. But if I will have 'url' for shared-key then how can I query for title-match and score-with-limit(less-than, greater-than-equal)

– Raghvendra Parashar
Dec 25 '14 at 6:07







Thanks for your response. But if I will have 'url' for shared-key then how can I query for title-match and score-with-limit(less-than, greater-than-equal)

– Raghvendra Parashar
Dec 25 '14 at 6:07















If the url field can limit the result set to a small number for example 100 records it should be fine.

– Antonios
Dec 25 '14 at 10:40





If the url field can limit the result set to a small number for example 100 records it should be fine.

– Antonios
Dec 25 '14 at 10:40


















draft saved

draft discarded




















































Thanks for contributing an answer to Database Administrators Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f86766%2fmongodb-sharding-what-should-be-the-sharding-key-if-we-want-to-find-records-wi%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Ronny Ackermann

Köttigit

MySQL 8.0.15 starts normally but any connection hangs