Region Merge Config
Learn how to configure Region Merge in TiKV.
TiKV replicates a segment of data in Regions via the Raft state machine. As data writes increase, a Region Split happens when the size of the region or the number of keys has reached a threshold. Conversely, if the size of the Region or the amount of keys shrinks because of data deletion, we can use Region Merge to merge adjacent regions that are smaller. This relieves some stress on Raftstore.
Region Merge is initiated by the Placement Driver (PD). The steps are:
PD polls the sizes and number of keys of all regions on the TiKV node.
When the region size is less than
max-merge-region-sizeor the number of keys the region includes is less than
max-merge-region-keys, PD performs Region Merge on the smaller of the two adjacent Regions.
- All replicas of the merged Regions must belong to the same set of TiKVs.
- Newly split Regions won’t be merged within the period of time specified by
- Region Merge won’t happen within the period of time specified by
split-merge-intervalafter PD starts or restarts.
- Region Merge won’t happen for two Regions that belong to different tables if
namespace-classifier = table(default).
Configure Region Merge
Region Merge is enabled by default. You can use
pd-ctl or the PD configuration file to configure Region Merge.
To enable Region Merge, set the following parameters to a non-zero value:
You can use
split-merge-interval to control the interval between the
For detailed descriptions on the above parameters, refer to PD Control.