The placement rule strategy will cause the number of regions to multiply

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: placement rule 策略会导致region数量成倍增加

| username: 林夕一指

[TiDB Usage Environment] Production Environment
[TiDB Version] v6.5.0
[Reproduction Path] After large-scale cleanup of empty partition placement rules, the number of regions and peer count will drop sharply.
[Encountered Problem: Problem Phenomenon and Impact]
[Attachment: Screenshot/Log/Monitoring]



| username: zhanggame1 | Original post link

I didn’t understand. You can count the number of regions and peers for each table before, what the placement rule is, and then how much it is after removing it.

| username: TiDBer_jYQINSnf | Original post link

Take a look at your placement rule and then compare it with the modified one. The information you provided only shows that the region peer has decreased, and the region has also decreased.

| username: 林夕一指 | Original post link

The image is not available for translation. Please provide the text content directly.

| username: zhanggame1 | Original post link

Before and after modifying the parameters, you can check the two views, INFORMATION_SCHEMA.TIKV_REGION_STATUS and INFORMATION_SCHEMA.TIKV_REGION_PEERS, and query the region_id to find out the number of regions, size, and number of peers for a specific table. Don’t look at the total amount; compare a specific table instead.

| username: dba远航 | Original post link

Haven’t encountered it.

| username: 林夕一指 | Original post link

When applying placement rules to existing data, the number of regions is actually unaffected. However, when configuring this strategy for partitions without any data, the number of regions will increase. But from the show table regions, the APPROXIMATE_SIZE of the newly added regions shows 31MB. It feels like this will occupy disk space, right?

| username: 双开门变频冰箱 | Original post link

Haven’t encountered it.

| username: zhanggame1 | Original post link

It feels quite strange, I’ll test it later. What is your rule, is it still 1 leader and 2 followers?

| username: 林夕一指 | Original post link

Defined a bu and fun tag.

| username: 林夕一指 | Original post link

It is 1 leader and 2 followers.

| username: TiDBer_jYQINSnf | Original post link

How does this increase the number of regions? I don’t understand.

| username: 小龙虾爱大龙虾 | Original post link

When setting placement rule rules for tables or partitions using placement rule in SQL, regions will be split according to the boundaries of the placement rule. The corresponding operator type is rule-split-region, which will lead to an increase in the number of regions. This is expected and can be observed through PD logs.

| username: 小龙虾爱大龙虾 | Original post link

When there is data in the table, this phenomenon is not very obvious because a table involves multiple regions. When the table is empty, one region corresponds to multiple tables. At this time, setting placement rules in SQL will result in many regions being split.

| username: zhanggame1 | Original post link

When the table is empty, one region can correspond to multiple tables.

Generally speaking, a newly created table usually has one table per region, right?

| username: TiDBer_jYQINSnf | Original post link

At most, one table will have one more region, it won’t be many more.

| username: 小龙虾爱大龙虾 | Original post link

When creating a new table, each table will have one region, TiDB 配置文件描述 | PingCAP 文档中心
However, it is possible for them to be merged together by PD, PD 配置文件描述 | PingCAP 文档中心

| username: zhanggame1 | Original post link

In fact, it is very difficult to trigger this. You can see in INFORMATION_SCHEMA.TIKV_REGION_STATUS that there is one regionid for multiple tables, which are generally system tables.

| username: 小龙虾爱大龙虾 | Original post link

Yes, because only adjacent regions can be merged, and the prerequisites for merging must be met.

| username: 林夕一指 | Original post link

Usually, it rises slowly, even when creating a new ordinary table, it doesn’t spike. However, when the database is configured with a placement rule and a large number of empty partitions are created in a partitioned table, it can easily rise. It’s quite worrisome to watch.