表分region,不理解的地方,请教

为提高效率,请提供以下信息,问题描述清晰能够更快得到解决:

【TiDB 版本】4.0.10

【问题描述】
一个表,默认1个region,及表下各索引也是一个region,我执行,一个索引分region,且分3个region,表也随着分了5个region,这是为什么?
再在该表的另一个索引分3个region,其表由之前5个region变为8个,这是为什么?
请教问题:
1、我只给索引分region,不给表分region,好像做不到
2、为什么给第一个索引分3个region,表也分了5个region,要不表不分region,要不表分3个region
3、给第二个索引分3个region,表新增3个region,与第一个索引分region,其表region数不一样

mysql> select region_id,index_name from information_schema.tikv_region_status where db_name=‘base’ and table_name=‘t1’;
±----------±---------------------+
| region_id | index_name |
±----------±---------------------+
| 2 | PRIMARY |
| 2 | I_ORDER_FIRST_SPELL |
| 2 | I_ORDER_FIRST_SPELL1 |
| 2 | NULL |
±----------±---------------------+
4 rows in set (0.15 sec)

mysql> show table t1 regions\G
*************************** 1. row ***************************
REGION_ID: 2
START_KEY: t_12495_
END_KEY:
LEADER_ID: 66
LEADER_STORE_ID: 4
PEERS: 3, 66, 87
SCATTERING: 0
WRITTEN_BYTES: 0
READ_BYTES: 0
APPROXIMATE_SIZE(MB): 105
APPROXIMATE_KEYS: 591105
1 row in set (0.02 sec)

mysql> split table t1 index i_order_first_spell between (0) and (60000) regions 3;
±-------------------±---------------------+
| TOTAL_SPLIT_REGION | SCATTER_FINISH_RATIO |
±-------------------±---------------------+
| 4 | 1 |
±-------------------±---------------------+
1 row in set (0.04 sec)

mysql> show table t1 regions\G
*************************** 1. row ***************************
REGION_ID: 2
START_KEY: t_12495_i_3_
END_KEY:
LEADER_ID: 66
LEADER_STORE_ID: 4
PEERS: 3, 66, 87
SCATTERING: 0
WRITTEN_BYTES: 0
READ_BYTES: 0
APPROXIMATE_SIZE(MB): 21
APPROXIMATE_KEYS: 118221
*************************** 2. row ***************************
REGION_ID: 31053
START_KEY: t_12495_
END_KEY: t_12495_i_2_
LEADER_ID: 31055
LEADER_STORE_ID: 4
PEERS: 31054, 31055, 31056
SCATTERING: 0
WRITTEN_BYTES: 0
READ_BYTES: 0
APPROXIMATE_SIZE(MB): 1
APPROXIMATE_KEYS: 15925
*************************** 3. row ***************************
REGION_ID: 31057
START_KEY: t_12495_i_2_
END_KEY: t_12495_i_2_061900800000000000000000004e20030000000000
LEADER_ID: 31058
LEADER_STORE_ID: 1
PEERS: 31058, 31059, 31060
SCATTERING: 0
WRITTEN_BYTES: 1325
READ_BYTES: 0
APPROXIMATE_SIZE(MB): 13
APPROXIMATE_KEYS: 61902
*************************** 4. row ***************************
REGION_ID: 31061
START_KEY: t_12495_i_2_061900800000000000000000004e20030000000000
END_KEY: t_12495_i_2_061900800000000000000000009c40030000000000
LEADER_ID: 31064
LEADER_STORE_ID: 5
PEERS: 31062, 31063, 31064
SCATTERING: 0
WRITTEN_BYTES: 1325
READ_BYTES: 0
APPROXIMATE_SIZE(MB): 1
APPROXIMATE_KEYS: 0
*************************** 5. row ***************************
REGION_ID: 31065
START_KEY: t_12495_i_2_061900800000000000000000009c40030000000000
END_KEY: t_12495_i_3_
LEADER_ID: 31066
LEADER_STORE_ID: 1
PEERS: 31066, 31067, 31068
SCATTERING: 0
WRITTEN_BYTES: 0
READ_BYTES: 0
APPROXIMATE_SIZE(MB): 1
APPROXIMATE_KEYS: 0
5 rows in set (0.03 sec)

mysql> select region_id,index_name from information_schema.tikv_region_status where db_name=‘base’ and table_name=‘t1’;
±----------±---------------------+
| region_id | index_name |
±----------±---------------------+
| 31065 | I_ORDER_FIRST_SPELL |
| 31053 | PRIMARY |
| 2 | I_ORDER_FIRST_SPELL1 |
| 2 | NULL |
| 31061 | I_ORDER_FIRST_SPELL |
| 31057 | I_ORDER_FIRST_SPELL |
±----------±---------------------+
6 rows in set (0.14 sec)
mysql> split table t1 index i_order_first_spell1 between (0) and (60000) regions 3;
±-------------------±---------------------+
| TOTAL_SPLIT_REGION | SCATTER_FINISH_RATIO |
±-------------------±---------------------+
| 3 | 1 |
±-------------------±---------------------+
1 row in set (0.03 sec)

mysql> show table t1 regions\G
*************************** 1. row ***************************
REGION_ID: 2
START_KEY: t_12495_i_4_
END_KEY:
LEADER_ID: 66
LEADER_STORE_ID: 4
PEERS: 3, 66, 87
SCATTERING: 0
WRITTEN_BYTES: 0
READ_BYTES: 0
APPROXIMATE_SIZE(MB): 24
APPROXIMATE_KEYS: 150283
*************************** 2. row ***************************
REGION_ID: 31053
START_KEY: t_12495_
END_KEY: t_12495_i_2_
LEADER_ID: 31055
LEADER_STORE_ID: 4
PEERS: 31054, 31055, 31056
SCATTERING: 0
WRITTEN_BYTES: 1481
READ_BYTES: 0
APPROXIMATE_SIZE(MB): 1
APPROXIMATE_KEYS: 15925
*************************** 3. row ***************************
REGION_ID: 31057
START_KEY: t_12495_i_2_
END_KEY: t_12495_i_2_061900800000000000000000004e20030000000000
LEADER_ID: 31058
LEADER_STORE_ID: 1
PEERS: 31058, 31059, 31060
SCATTERING: 0
WRITTEN_BYTES: 0
READ_BYTES: 0
APPROXIMATE_SIZE(MB): 13
APPROXIMATE_KEYS: 61902
*************************** 4. row ***************************
REGION_ID: 31061
START_KEY: t_12495_i_2_061900800000000000000000004e20030000000000
END_KEY: t_12495_i_2_061900800000000000000000009c40030000000000
LEADER_ID: 31064
LEADER_STORE_ID: 5
PEERS: 31062, 31063, 31064
SCATTERING: 0
WRITTEN_BYTES: 0
READ_BYTES: 0
APPROXIMATE_SIZE(MB): 1
APPROXIMATE_KEYS: 0
*************************** 5. row ***************************
REGION_ID: 31065
START_KEY: t_12495_i_2_061900800000000000000000009c40030000000000
END_KEY: t_12495_i_3_
LEADER_ID: 31066
LEADER_STORE_ID: 1
PEERS: 31066, 31067, 31068
SCATTERING: 0
WRITTEN_BYTES: 29
READ_BYTES: 0
APPROXIMATE_SIZE(MB): 1
APPROXIMATE_KEYS: 0
*************************** 6. row ***************************
REGION_ID: 31069
START_KEY: t_12495_i_3_
END_KEY: t_12495_i_3_061900800000000000000000004e20030000000000
LEADER_ID: 31071
LEADER_STORE_ID: 4
PEERS: 31070, 31071, 31072
SCATTERING: 0
WRITTEN_BYTES: 0
READ_BYTES: 0
APPROXIMATE_SIZE(MB): 13
APPROXIMATE_KEYS: 5213
*************************** 7. row ***************************
REGION_ID: 31073
START_KEY: t_12495_i_3_061900800000000000000000004e20030000000000
END_KEY: t_12495_i_3_061900800000000000000000009c40030000000000
LEADER_ID: 31076
LEADER_STORE_ID: 5
PEERS: 31074, 31075, 31076
SCATTERING: 0
WRITTEN_BYTES: 1325
READ_BYTES: 0
APPROXIMATE_SIZE(MB): 1
APPROXIMATE_KEYS: 0
*************************** 8. row ***************************
REGION_ID: 31077
START_KEY: t_12495_i_3_061900800000000000000000009c40030000000000
END_KEY: t_12495_i_4_
LEADER_ID: 31078
LEADER_STORE_ID: 1
PEERS: 31078, 31079, 31080
SCATTERING: 0
WRITTEN_BYTES: 1481
READ_BYTES: 0
APPROXIMATE_SIZE(MB): 1
APPROXIMATE_KEYS: 0
8 rows in set (0.04 sec)

mysql> select region_id,index_name from information_schema.tikv_region_status where db_name=‘base’ and table_name=‘t1’;
±----------±---------------------+
| region_id | index_name |
±----------±---------------------+
| 31065 | I_ORDER_FIRST_SPELL |
| 31073 | I_ORDER_FIRST_SPELL1 |
| 31069 | I_ORDER_FIRST_SPELL1 |
| 31053 | PRIMARY |
| 2 | NULL |
| 31061 | I_ORDER_FIRST_SPELL |
| 31057 | I_ORDER_FIRST_SPELL |
| 31077 | I_ORDER_FIRST_SPELL1 |
±----------±---------------------+
8 rows in set (0.14 sec)

mysql>

表结构可以提供一下么,我这边测试一下 split index 看起来正常

mysql> show create table split_tb;
+----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table    | Create Table                                                                                                                                                                                  |
+----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| split_tb | CREATE TABLE `split_tb` (
  `id` int(11) NOT NULL,
  `name` varchar(20) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin |
+----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.14 sec)

mysql> show table split_tb regions;
+-----------+-----------+---------+-----------+-----------------+-------+------------+---------------+------------+----------------------+------------------+
| REGION_ID | START_KEY | END_KEY | LEADER_ID | LEADER_STORE_ID | PEERS | SCATTERING | WRITTEN_BYTES | READ_BYTES | APPROXIMATE_SIZE(MB) | APPROXIMATE_KEYS |
+-----------+-----------+---------+-----------+-----------------+-------+------------+---------------+------------+----------------------+------------------+
|         2 | t_77_     |         |         3 |               1 | 3     |          0 |             0 |          0 |                    1 |                0 |
+-----------+-----------+---------+-----------+-----------------+-------+------------+---------------+------------+----------------------+------------------+
1 row in set (0.04 sec)

mysql> split table split_tb index name between("") and ("z") regions 3;
+--------------------+----------------------+
| TOTAL_SPLIT_REGION | SCATTER_FINISH_RATIO |
+--------------------+----------------------+
|                  3 |                    1 |
+--------------------+----------------------+
1 row in set (0.05 sec)

mysql> show table split_tb regions;
+-----------+-----------------------------+-----------------------------+-----------+-----------------+-------+------------+---------------+------------+----------------------+------------------+
| REGION_ID | START_KEY                   | END_KEY                     | LEADER_ID | LEADER_STORE_ID | PEERS | SCATTERING | WRITTEN_BYTES | READ_BYTES | APPROXIMATE_SIZE(MB) | APPROXIMATE_KEYS |
+-----------+-----------------------------+-----------------------------+-----------+-----------------+-------+------------+---------------+------------+----------------------+------------------+
|         2 | t_77_i_2_                   |                             |         3 |               1 | 3     |          0 |             0 |          0 |                    1 |                0 |
|        69 | t_77_                       | t_77_i_1_0128aaaaaaaaaaaaaa |        70 |               1 | 70    |          0 |        104836 |          0 |                    1 |                0 |
|        71 | t_77_i_1_0128aaaaaaaaaaaaaa | t_77_i_1_015155555555555554 |        72 |               1 | 72    |          0 |        104836 |          0 |                    1 |                0 |
|        73 | t_77_i_1_015155555555555554 | t_77_i_2_                   |        74 |               1 | 74    |          0 |        104836 |          0 |                    1 |                0 |
+-----------+-----------------------------+-----------------------------+-----------+-----------------+-------+------------+---------------+------------+----------------------+------------------+
4 rows in set (0.05 sec)

mysql> desc t1;
±------------------±--------------±-----±-----±--------±------+
| Field | Type | Null | Key | Default | Extra |
±------------------±--------------±-----±-----±--------±------+
| ID | decimal(25,0) | NO | PRI | NULL | |
| ORDER_ITEM | varchar(100) | NO | | NULL | |
| FIRST_SPELL | varchar(100) | NO | | NULL | |
| ORDER_TYPE | int(6) | NO | | NULL | |
| SAMPLE_CODE | int(8) | YES | | NULL | |
| EXEC_DEPT_ID | decimal(25,0) | YES | | NULL | |
| APPT_REQUIRED_IND | tinyint(1) | YES | | NULL | |
| BUSINESS_TYPE | tinyint(1) | NO | | 3 | |
| USING_SIGN | tinyint(1) | NO | | 1 | |
| REMARKS | varchar(256) | YES | | NULL | |
| MODIFER | decimal(25,0) | YES | | NULL | |
| MODIFY_DATE | datetime | YES | | NULL | |
| HOSP_ID | decimal(25,0) | YES | MUL | NULL | |
| ORDER_ITEM1 | varchar(50) | YES | | NULL | |
| FIRST_SPELL1 | varchar(50) | YES | | NULL | |
| OPR_LEVEL | tinyint(2) | YES | | NULL | |
| MATCHING_SIGN | tinyint(1) | NO | | NULL | |
| EYE_TYPE_SIGN | tinyint(1) | YES | | NULL | |
| EYE_ORGAN_SIGN | tinyint(1) | YES | | NULL | |
| BODY_ORGAN_SIGN | tinyint(1) | YES | | NULL | |
| EYE_ORGAN | varchar(256) | YES | | NULL | |
| BODY_ORGAN | varchar(256) | YES | | NULL | |
±------------------±--------------±-----±-----±--------±------+
22 rows in set (0.00 sec)

可以提供 show create table 的结果么,方便复现问题

 CREATE TABLE `t1` (
  `ID` decimal(25,0) NOT NULL COMMENT 'ID',
  `ORDER_ITEM` varchar(100) NOT NULL COMMENT '医嘱项目名称',
  `FIRST_SPELL` varchar(100) NOT NULL COMMENT '首拼码',
  `ORDER_TYPE` int(6) NOT NULL COMMENT '医嘱项目类型(码表:recipe_kind)',
  `SAMPLE_CODE` int(8) DEFAULT NULL COMMENT '样本代码(血液、尿、体液等样本的参数表值)(码表:sample_code)',
  `EXEC_DEPT_ID` decimal(25,0) DEFAULT NULL COMMENT '默认执行科室(为空表示开方科室为执行科室)',
  `APPT_REQUIRED_IND` tinyint(1) DEFAULT NULL COMMENT '需要申请标识(0不需要申请1需要申请)',
  `BUSINESS_TYPE` tinyint(1) NOT NULL DEFAULT '3' COMMENT '门诊住院标识 码表:(business_type)',
  `USING_SIGN` tinyint(1) NOT NULL DEFAULT '1' COMMENT '启停标识(1启用0停用)',
  `REMARKS` varchar(256) DEFAULT NULL COMMENT '备注',
  `MODIFER` decimal(25,0) DEFAULT NULL COMMENT '修改人',
  `MODIFY_DATE` datetime DEFAULT NULL COMMENT '修改时间',
  `HOSP_ID` decimal(25,0) DEFAULT NULL COMMENT '机构id',
  `ORDER_ITEM1` varchar(50) DEFAULT NULL COMMENT '医嘱项目名称1(如:存药品商品名称)',
  `FIRST_SPELL1` varchar(50) DEFAULT NULL COMMENT '医嘱项目首拼码1(如:存药品商品名拼音)',
  `OPR_LEVEL` tinyint(2) DEFAULT NULL COMMENT '手术级别(码表:opr_level)',
  `MATCHING_SIGN` tinyint(1) NOT NULL COMMENT '匹配途径(1直接匹配、2按申请内容匹配)',
  `EYE_TYPE_SIGN` tinyint(1) DEFAULT NULL COMMENT '眼别标识(1有关0无关)',
  `EYE_ORGAN_SIGN` tinyint(1) DEFAULT NULL COMMENT '眼内部位标识(1有关0无关)',
  `BODY_ORGAN_SIGN` tinyint(1) DEFAULT NULL COMMENT '全身部位标识(1有关0无关)',
  `EYE_ORGAN` varchar(256) DEFAULT NULL COMMENT '眼内检查部位(码表:eye_organ;支持多部位,并用逗号隔开)',
  `BODY_ORGAN` varchar(256) DEFAULT NULL COMMENT '全身检查部位(码表:body_organ;支持多部位,并用逗号隔开)',
  PRIMARY KEY (`ID`),
  KEY `I_ORDER_FIRST_SPELL` (`HOSP_ID`,`FIRST_SPELL`),
  KEY `I_ORDER_FIRST_SPELL1` (`HOSP_ID`,`FIRST_SPELL1`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='医嘱项目字典' ;
mysql> source /tmp/a.sql;
Query OK, 0 rows affected (0.14 sec)

mysql> show table t1 regions;
+-----------+-----------+---------+-----------+-----------------+-------+------------+---------------+------------+----------------------+------------------+
| REGION_ID | START_KEY | END_KEY | LEADER_ID | LEADER_STORE_ID | PEERS | SCATTERING | WRITTEN_BYTES | READ_BYTES | APPROXIMATE_SIZE(MB) | APPROXIMATE_KEYS |
+-----------+-----------+---------+-----------+-----------------+-------+------------+---------------+------------+----------------------+------------------+
|         2 | t_48_     |         |         3 |               1 | 3     |          0 |           269 |          0 |                    1 |                0 |
+-----------+-----------+---------+-----------+-----------------+-------+------------+---------------+------------+----------------------+------------------+
1 row in set (0.04 sec)

mysql> select region_id,table_name,is_index,index_id,index_name from tikv_region_status where table_name = 't1';
+-----------+------------+----------+----------+----------------------+
| region_id | table_name | is_index | index_id | index_name           |
+-----------+------------+----------+----------+----------------------+
|         2 | t1         |        1 |        1 | PRIMARY              |
|         2 | t1         |        1 |        2 | I_ORDER_FIRST_SPELL  |
|         2 | t1         |        1 |        3 | I_ORDER_FIRST_SPELL1 |
|         2 | t1         |        0 |     NULL | NULL                 |
+-----------+------------+----------+----------+----------------------+
4 rows in set (0.05 sec)

mysql>  split table t1 index i_order_first_spell between (0) and (60000) regions 3;
+--------------------+----------------------+
| TOTAL_SPLIT_REGION | SCATTER_FINISH_RATIO |
+--------------------+----------------------+
|                  4 |                    1 |
+--------------------+----------------------+
1 row in set (0.38 sec)

mysql> show table t1 regions;
+-----------+-----------------------------------------------------+-----------------------------------------------------+-----------+-----------------+-------+------------+---------------+------------+----------------------+------------------+
| REGION_ID | START_KEY                                           | END_KEY                                             | LEADER_ID | LEADER_STORE_ID | PEERS | SCATTERING | WRITTEN_BYTES | READ_BYTES | APPROXIMATE_SIZE(MB) | APPROXIMATE_KEYS |
+-----------+-----------------------------------------------------+-----------------------------------------------------+-----------+-----------------+-------+------------+---------------+------------+----------------------+------------------+
|         2 | t_48_i_3_                                           |                                                     |         3 |               1 | 3     |          0 |             0 |          0 |                    1 |                0 |
|      2013 | t_48_                                               | t_48_i_2_                                           |      2014 |               1 | 2014  |          0 |             0 |          0 |                    1 |                0 |
|      2015 | t_48_i_2_                                           | t_48_i_2_061900800000000000000000004e20030000000000 |      2016 |               1 | 2016  |          0 |             0 |          0 |                    1 |                0 |
|      2017 | t_48_i_2_061900800000000000000000004e20030000000000 | t_48_i_2_061900800000000000000000009c40030000000000 |      2018 |               1 | 2018  |          0 |             0 |          0 |                    1 |                0 |
|      2019 | t_48_i_2_061900800000000000000000009c40030000000000 | t_48_i_3_                                           |      2020 |               1 | 2020  |          0 |             0 |          0 |                    1 |                0 |
+-----------+-----------------------------------------------------+-----------------------------------------------------+-----------+-----------------+-------+------------+---------------+------------+----------------------+------------------+
5 rows in set (0.05 sec)

mysql> select region_id,table_name,is_index,index_id,index_name from tikv_region_status where table_name = 't1';
+-----------+------------+----------+----------+----------------------+
| region_id | table_name | is_index | index_id | index_name           |
+-----------+------------+----------+----------+----------------------+
|         2 | t1         |        1 |        3 | I_ORDER_FIRST_SPELL1 |
|         2 | t1         |        0 |     NULL | NULL                 |
|      2019 | t1         |        1 |        2 | I_ORDER_FIRST_SPELL  |
|      2013 | t1         |        1 |        1 | PRIMARY              |
|      2015 | t1         |        1 |        2 | I_ORDER_FIRST_SPELL  |
|      2017 | t1         |        1 |        2 | I_ORDER_FIRST_SPELL  |
+-----------+------------+----------+----------+----------------------+
6 rows in set (0.04 sec)

mysql> split table t1 index i_order_first_spell1 between (0) and (60000) regions 3;
+--------------------+----------------------+
| TOTAL_SPLIT_REGION | SCATTER_FINISH_RATIO |
+--------------------+----------------------+
|                  3 |                    1 |
+--------------------+----------------------+
1 row in set (0.54 sec)

mysql> show table t1 regions;
+-----------+-----------------------------------------------------+-----------------------------------------------------+-----------+-----------------+-------+------------+---------------+------------+----------------------+------------------+
| REGION_ID | START_KEY                                           | END_KEY                                             | LEADER_ID | LEADER_STORE_ID | PEERS | SCATTERING | WRITTEN_BYTES | READ_BYTES | APPROXIMATE_SIZE(MB) | APPROXIMATE_KEYS |
+-----------+-----------------------------------------------------+-----------------------------------------------------+-----------+-----------------+-------+------------+---------------+------------+----------------------+------------------+
|         2 | t_48_i_4_                                           |                                                     |         3 |               1 | 3     |          0 |             0 |          0 |                    1 |                0 |
|      2013 | t_48_                                               | t_48_i_2_                                           |      2014 |               1 | 2014  |          0 |           233 |          0 |                    1 |                0 |
|      2015 | t_48_i_2_                                           | t_48_i_2_061900800000000000000000004e20030000000000 |      2016 |               1 | 2016  |          0 |           113 |          0 |                    1 |                0 |
|      2017 | t_48_i_2_061900800000000000000000004e20030000000000 | t_48_i_2_061900800000000000000000009c40030000000000 |      2018 |               1 | 2018  |          0 |           113 |          0 |                    1 |                0 |
|      2019 | t_48_i_2_061900800000000000000000009c40030000000000 | t_48_i_3_                                           |      2020 |               1 | 2020  |          0 |            29 |          0 |                    1 |                0 |
|      2021 | t_48_i_3_                                           | t_48_i_3_061900800000000000000000004e20030000000000 |      2022 |               1 | 2022  |          0 |             0 |          0 |                    1 |                0 |
|      2023 | t_48_i_3_061900800000000000000000004e20030000000000 | t_48_i_3_061900800000000000000000009c40030000000000 |      2024 |               1 | 2024  |          0 |             0 |          0 |                    1 |                0 |
|      2025 | t_48_i_3_061900800000000000000000009c40030000000000 | t_48_i_4_                                           |      2026 |               1 | 2026  |          0 |             0 |          0 |                    1 |                0 |
+-----------+-----------------------------------------------------+-----------------------------------------------------+-----------+-----------------+-------+------------+---------------+------------+----------------------+------------------+
8 rows in set (0.05 sec)

mysql> select region_id,table_name,is_index,index_id,index_name from tikv_region_status where table_name = 't1';
+-----------+------------+----------+----------+----------------------+
| region_id | table_name | is_index | index_id | index_name           |
+-----------+------------+----------+----------+----------------------+
|      2019 | t1         |        1 |        2 | I_ORDER_FIRST_SPELL  |
|      2021 | t1         |        1 |        3 | I_ORDER_FIRST_SPELL1 |
|      2013 | t1         |        1 |        1 | PRIMARY              |
|      2015 | t1         |        1 |        2 | I_ORDER_FIRST_SPELL  |
|      2017 | t1         |        1 |        2 | I_ORDER_FIRST_SPELL  |
|      2023 | t1         |        1 |        3 | I_ORDER_FIRST_SPELL1 |
|      2025 | t1         |        1 |        3 | I_ORDER_FIRST_SPELL1 |
|         2 | t1         |        0 |     NULL | NULL                 |
+-----------+------------+----------+----------+----------------------+
8 rows in set (0.13 sec)

因为底层数据是 kv 存储,所以数据是按照字典序进行排序的,最初的状态是数据和索引都存放在一个 region 中,范围是 t_48_ 到 “ ”。之后对 index 进行切分, 结合 TiDB 中关系模型到 kv 模型 的映射关系,是需要对 key 范围在 t_48_i_2 到 t_48_i_3 之间的数据切分出 3 个 region。那还会剩余 t_48_ 到 t_48_i_2 之间的数据需要一个 region,按照字典序规则会存放 数据和 index_id 为 1 的索引数据, t_48_i_3 到 “” 之间的数据需要一个 region ,用于存放 index_id 为 3 的索引数据,所以总共是 5 个region。

上面的 2 是 I_ORDER_FIRST_SPELL 索引的 index_id ,3 是 I_ORDER_FIRST_SPELL1 的 index_id 。
split I_ORDER_FIRST_SPELL1 的时候,是对 t_48_i_3 到 “” 之间的数据进行划分,所以增加了 3 个 region ,变成了 8 个 region。因为表中没有 index_id 为 4 的索引,所以不需要预留 t_48_i_4 到 “” 之间的索引 region。

此话题已在最后回复的 1 分钟后被自动关闭。不再允许新回复。