content_image/851302.jpg
## Chunk Size 

<img src='content_image/851302.jpg'>

The default chunk size in MongoDB is 64 megabytes. You can increase or reduce the chunk size (page 727), mindful of its effect on the cluster’s efficiency. 

1. Small chunks lead to a more even distribution of data at the expense of more frequent migrations. This creates expense at the query routing ( mongos ) layer. 

2. Large chunks lead to fewer migrations. This is more efficient both from the networking perspective and in terms of internal overhead at the query routing layer. But, these efficiencies come at the expense of a potentially more uneven distribution of data. 

3. Chunk size affects the Maximum Number of Documents Per Chunk to Migrate . 

For many deployments, it makes sense to avoid frequent and potentially spurious migrations at the expense of a slightly less evenly distributed data set. 

## Limitations 

Changing the chunk size affects when chunks split but there are some limitations to its effects. 

• Automatic splitting only occurs during inserts or updates. If you lower the chunk size, it may take time for all chunks to split to the new size. 

• Splits cannot be “undone”. If you increase the chunk size, existing chunks must grow through inserts or updates until they reach the new size. 

Note: Chunk ranges are inclusive of the lower boundary and exclusive of the upper boundary. 

## Indivisible Chunks 

In some cases, chunks can grow beyond the specified chunk size (page 688) but cannot undergo a split; e.g. if a chunk represents a single shard key value. See Considerations for Selecting Shard Keys (page 694) for considerations for selecting a shard key. 

## Shard Key Indexes 

All sharded collections must have an index that starts with the shard key . If you shard a collection without any documents and without such an index, the shardCollection command will create the index on the shard key. If the collection already has documents, you must create the index before using shardCollection . 

