Sharding key question

26 views
Skip to first unread message

Daniel

unread,
Sep 28, 2012, 9:10:50 AM9/28/12
to mongod...@googlegroups.com
Hi,

most of my documents consists of a unique group_id which groups documents. This group_id is in nearly every query I have. But  I also have _id in some queries. My current sharding key consists of a compound of  {group_id, _id}. Does this make sense at all? Or does the sharding key needs to be in every query completely? Or does MongoDB also uses partial sharding keys to hit the correct shard?

So if a query consists uses a query with qroup_id, field_A, field_B, will it hit the shards first where group_id is used also if _id is not used in the specific query?

Thanks & regards..

Daniel

Kay

unread,
Sep 28, 2012, 12:56:57 PM9/28/12
to mongod...@googlegroups.com
Hi Daniel -- 
queries that don't contain the complete shard key will use scatter/gather queries.  However, if the cardinality of the group_id is low enough, you should probably use _id as well to prevent oversized chunks.

Regards,

Kay

Daniel

unread,
Sep 28, 2012, 1:04:19 PM9/28/12
to mongod...@googlegroups.com
Ok, thanks for the scatter query info. Didn't know this.

Yes, _id is part of my sharding key, but it's not available in every query.

Daniel
Reply all
Reply to author
Forward
0 new messages