Frage

I have a shard key based on {Field1:1,Field2:1} where Field2 can be null. So if two documents have same value for Field1 and null/empty value of Field2 then are they considered to belong to the same shard key/non split-able??

War es hilfreich?

Lösung

In MongoDB 'null' is just another value so two documents that have the same values for field1 (some non-null) and same value for field2 (null) have the same value for the shard key and will always be in the same "chunk".

Andere Tipps

As per MongoDB BOL Here The shard key determines the distribution of the collection’s documents among the cluster’s shards. The shard key is either an indexed field or indexed compound fields that exists in every document in the collection.

MongoDB partitions data in the collection using ranges of shard key values. Each range defines a non-overlapping range of shard key values and is associated with a chunk.

MongoDB attempts to distribute chunks evenly among the shards in the cluster. The shard key has a direct relationship to the effectiveness of chunk distribution.

Note: Once you shard a collection, the shard key and the shard key values are immutable; i.e. You cannot select a different shard key for that collection. You cannot update the values of the shard key fields.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit dba.stackexchange
scroll top