@Aasawari Thank you for your response but I still don’t clear much, reason is, for example I have a shardkey like this:
{oemNumber: 'hashed', zipCode: 1, supplierId: 1}
Sample data like:
[
{
oemNumber: "ABC",
zipCode: 12345,
supplierId: 10
},
{
oemNumber: "ABC", // same oemNumber
zipCode: 67890,
supplierId: 15
}
]
Base on my understand, for above key, the oemNumber field is hashed, like this:
hashFunc("ABC") // ===> 123456789
Two above records have same value ( “ABC” ), hash function will generate ‘ABC’ to ONE fixed number, ex: 123456789, and due to hashed value are SAME so 2 above records will be put into one chunk in one shard.
In this case, monotonically increasing shard key is an issue, yes, but if we add more fields (zipcode, supplierId) then hashed function also just generate by value ‘ABC’
Because we can just hash one field (oemNumber), so I don’t understand what role of “zipCode” and “supplierId” in hash function, OR are you mean that the hash function will accept ALL 3 parameters like this:
hashFunc(oemNumber, zipCode, supplierId)
If it accepts 3 parameters then why we just can define 1 hashed filed [ oemNumber: ‘hashed’ ] , why we don’t define shardkey like this:
{oemNumber: 'hashed', zipCode: 'hashed', supplierId: 'hashed'}
Please teach me, thank you !