Hi,
I wonder if i should choose more precise shard key or have larger than 64MB chunks.
Here is detailed description of my problem:
My collection "Posts" contain posts which belongs to "Projects" (each "Posts" document contains projectId field). All operations i do always with projectId = ... in query condition, so at the first sight, the best shard key is projectId. Very often i also use "createdDate" field in query condition, but not always.
So i created collection Posts sharded by projectId key. But i realized, that some projects(5% of all projects) contains so many mentions, that total size of all documents with the same projectId will be larger than default chunk size (64MB).
Should i choose more specyfic shard key (eg compound key: projectId, createdDate) to avoid larger chunks than 64MB or should i let the chunks grow more than 64MB? I want to focus on fast read queries(especially aggregations).
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/CAOe6dJDe1TkJEnuewns_M5g02M5aKhC5hDCnnsbdwTOZHv5JxQ%40mail.gmail.com.
--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
For other MongoDB technical support options, see: http://www.mongodb.org/about/support/.
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at http://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/58a3310a-c74f-4152-8140-07c3cb3a4d85%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
For other MongoDB technical support options, see: http://www.mongodb.org/about/support/.
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at http://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/ddaa9a88-e34c-4a1c-989a-d05a0a9832d6%40googlegroups.com.
1.I tried to shard by (projectId,url) but i've got error:
Shard Key must be less than 512 bytes#0
Sometimes url is longer, so it is impossible to use URL in shard key.
2. I tried to shard by partly hashed index: db.mentions_old.ensureIndex( { sid:1,u: "hashed" } ) , but it is impossible to create such index ( "err" : "Currently only single field hashed index supported.")
So i can't shard by (projectId,url)
The last solution which remains is to shard by (projectId,_id) pair, but i i must resolve problem i wrote before:
"can't shard collection '...' with unique index on { projectId: 1, url: 1 } and proposed shard key { projectId: 1.0, _id: 1.0 }. Uniqueness can't be maintained unless shard key is a prefix"
Do you have any advice how to shard by (projectId,_id) pair and still have unique contraint in MongoDB on (projectId,url) pair?
Is it possible to have shard key with hased part? Something like this: {projectId:1,hashed(url):1)} ?