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 and 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 meta information of Regions constantly.
If the region size is less than max-merge-region-size
and the number of keys the region includes is less than max-merge-region-keys
, PD performs Region Merge on the region with the smaller one of the two adjacent Regions.
Note:
split-merge-interval
.split-merge-interval
after PD starts or restarts.namespace-classifier = table
(default).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:
max-merge-region-size
max-merge-region-keys
merge-schedule-limit
You can use split-merge-interval
to control the interval between the split
and merge
operations.
For detailed descriptions on the above parameters, refer to PD Control.
具体命令为:
tiup ctl:v6.5.3 pd config set max-merge-region-size 0
tiup ctl:v6.5.3 pd config set max-merge-region-keys 0
tiup ctl:v6.5.3 pd config set merge-schedule-limit 0