How to determine start key and end key for new split region in tikv?

When one region need to be split, How does pd determine the start key and end key for the new region.

for example. there is one region with start key “abc” and end key “mbd”, and the region size is increasing to 90mb. so it should be split to two new region. what is the strategy for calculating the start key and end key for the two new region?

Typically, the split key is determined by tikv. tikv maintains some statistics for each region’s data distribution, and when a split is needed tikv selects a key based on the statistics to split the region into the desired sizes.

Hi disksing, Thanks for your replay. Could you please teach me where to find the statistics-related code in tikv project?

You can find it under components/raftstore/src/store/fsm/peer.rs. Highlight key word: region_buckets.

1 Like