草庐IT

AnotherIDThatMatters

全部标签

c# - 使用复合索引分片 Mongodb 集合

我有一个需要分片的mongo集合。我很难理解文档;我想过以两种方式做到这一点。我的文档:publicclassMyShardedDocument{publicintDocID;publicintAnotherIDThatMatters;}方法一:添加名为ShardKey=DocID.ToString()+AnotherIDThatMatters.ToString()的属性在ShardKey上添加索引sh.shardCollection("myDB.myCollection",{"ShardKey":1})方法二:在DocID上添加复合索引,AnotherIDThatMatterssh.