tidb 建表的时候会分配多少个region?

测试了一把,咋感觉PRE_SPLIT_REGIONS 这个参数没起作用呢。

MySQL [test]> create table test (id int primary key );
Query OK, 0 rows affected (0.10 sec)

MySQL [test]> show table test regions;
+-----------+-----------+---------+-----------+-----------------+---------------------------------+------------+---------------+------------+----------------------+------------------+
| REGION_ID | START_KEY | END_KEY | LEADER_ID | LEADER_STORE_ID | PEERS                           | SCATTERING | WRITTEN_BYTES | READ_BYTES | APPROXIMATE_SIZE(MB) | APPROXIMATE_KEYS |
+-----------+-----------+---------+-----------+-----------------+---------------------------------+------------+---------------+------------+----------------------+------------------+
| 111528001 | t_2858_   |         | 111528003 |       110997197 | 111528003, 111528505, 111530519 |          0 |            50 |          0 |                    1 |                0 |
+-----------+-----------+---------+-----------+-----------------+---------------------------------+------------+---------------+------------+----------------------+------------------+
1 row in set (0.00 sec)

MySQL [test]> insert into  test VALUES (1),(2),(3),(4);
Query OK, 4 rows affected (0.00 sec)
Records: 4  Duplicates: 0  Warnings: 0

MySQL [test]> show table test regions;
+-----------+-----------+---------+-----------+-----------------+---------------------------------+------------+---------------+------------+----------------------+------------------+
| REGION_ID | START_KEY | END_KEY | LEADER_ID | LEADER_STORE_ID | PEERS                           | SCATTERING | WRITTEN_BYTES | READ_BYTES | APPROXIMATE_SIZE(MB) | APPROXIMATE_KEYS |
+-----------+-----------+---------+-----------+-----------------+---------------------------------+------------+---------------+------------+----------------------+------------------+
| 111528001 | t_2858_   |         | 111528003 |       110997197 | 111528003, 111528505, 111530519 |          0 |            50 |          0 |                    1 |                0 |
+-----------+-----------+---------+-----------+-----------------+---------------------------------+------------+---------------+------------+----------------------+------------------+
1 row in set (0.00 sec)

MySQL [test]> create table test2 (id int primary key ) PRE_SPLIT_REGIONS = 2;
Query OK, 0 rows affected (0.09 sec)

MySQL [test]> show table test2 regions;
+-----------+-----------+---------+-----------+-----------------+---------------------------------+------------+---------------+------------+----------------------+------------------+
| REGION_ID | START_KEY | END_KEY | LEADER_ID | LEADER_STORE_ID | PEERS                           | SCATTERING | WRITTEN_BYTES | READ_BYTES | APPROXIMATE_SIZE(MB) | APPROXIMATE_KEYS |
+-----------+-----------+---------+-----------+-----------------+---------------------------------+------------+---------------+------------+----------------------+------------------+
| 111528001 | t_2860_   |         | 111528003 |       110997197 | 111528003, 111528505, 111530519 |          0 |             0 |          0 |                    1 |                0 |
+-----------+-----------+---------+-----------+-----------------+---------------------------------+------------+---------------+------------+----------------------+------------------+
1 row in set (0.00 sec)

MySQL [test]> insert into  test2 VALUES (1),(2),(3),(4);
Query OK, 4 rows affected (0.01 sec)
Records: 4  Duplicates: 0  Warnings: 0

MySQL [test]> show table test2 regions;
+-----------+-----------+---------+-----------+-----------------+---------------------------------+------------+---------------+------------+----------------------+------------------+
| REGION_ID | START_KEY | END_KEY | LEADER_ID | LEADER_STORE_ID | PEERS                           | SCATTERING | WRITTEN_BYTES | READ_BYTES | APPROXIMATE_SIZE(MB) | APPROXIMATE_KEYS |
+-----------+-----------+---------+-----------+-----------------+---------------------------------+------------+---------------+------------+----------------------+------------------+
| 111528001 | t_2860_   |         | 111528003 |       110997197 | 111528003, 111528505, 111530519 |          0 |             0 |          0 |                    1 |                0 |
+-----------+-----------+---------+-----------+-----------------+---------------------------------+------------+---------------+------------+----------------------+------------------+
1 row in set (0.00 sec)

MySQL [test]> create table test3 (id int primary key ) PRE_SPLIT_REGIONS = 4;
Query OK, 0 rows affected (0.08 sec)

MySQL [test]> show table test3 regions;
+-----------+-----------+---------+-----------+-----------------+---------------------------------+------------+---------------+------------+----------------------+------------------+
| REGION_ID | START_KEY | END_KEY | LEADER_ID | LEADER_STORE_ID | PEERS                           | SCATTERING | WRITTEN_BYTES | READ_BYTES | APPROXIMATE_SIZE(MB) | APPROXIMATE_KEYS |
+-----------+-----------+---------+-----------+-----------------+---------------------------------+------------+---------------+------------+----------------------+------------------+
| 111528001 | t_2862_   |         | 111528003 |       110997197 | 111528003, 111528505, 111530519 |          0 |           547 |          0 |                    1 |                0 |
+-----------+-----------+---------+-----------+-----------------+---------------------------------+------------+---------------+------------+----------------------+------------------+
1 row in set (0.00 sec)

MySQL [test]> select version();
+--------------------+
| version()          |
+--------------------+
| 5.7.25-TiDB-v6.1.0 |
+--------------------+
1 row in set (0.00 sec)

MySQL [test]> select tidb_version();
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version()                                                                                                                                                                                                                                                                                                       |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v6.1.0
Edition: Community
Git Commit Hash: 1a89decdb192cbdce6a7b0020d71128bc964d30f
Git Branch: heads/refs/tags/v6.1.0
UTC Build Time: 2022-06-05 05:15:11
GoVersion: go1.18.2
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

MySQL [test]>