TiDB在建表时如何放置全新的Region?

创建表会为表分配一个 table_id,table 的 key 的格式是一定的,所以就能确定范围


MySQL [information_schema]> select region_id,tidb_decode_key(START_KEY),tidb_decode_key(END_KEY),min(table_id) from TIKV_REGION_STATUS group by region_id,START_KEY,END_KEY order by min(table_id);+-----------+---------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------+---------------------+
| region_id | tidb_decode_key(START_KEY)                                                                              | tidb_decode_key(END_KEY)                                                                                | min(table_id)       |
+-----------+---------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------+---------------------+
|         2 | 7800000100000000FB                                                                                      |                                                                                                         |                NULL |
|        14 | 7800000000000000FB                                                                                      | 7800000100000000FB                                                                                      |                NULL |
|       262 | 6D00000000000000F8                                                                                      | 6E00000000000000F8                                                                                      |                NULL |
|       258 |                                                                                                         | 6D00000000000000F8                                                                                      |                NULL |
|        10 | 7200000000000000FB                                                                                      | 7200000100000000FB                                                                                      |                NULL |
|         8 | 6E00000000000000F8                                                                                      | 7200000000000000FB                                                                                      |                NULL |
|      1101 | 7200000100000000FB                                                                                      | {"handle":{"c_d_id":"7","c_id":"1066","c_w_id":"1"},"table_id":110}                                     |                   4 |
|      1013 | {"handle":{"c_d_id":"1","c_id":"1479","c_w_id":"18"},"table_id":110}                                    | {"table_id":112}                                                                                        |                 110 |
|      1077 | {"handle":{"c_d_id":"10","c_id":"2710","c_w_id":"3"},"table_id":110}                                    | {"handle":{"c_d_id":"7","c_id":"2326","c_w_id":"8"},"table_id":110}                                     |                 110 |
|      1109 | {"handle":{"c_d_id":"4","c_id":"1863","c_w_id":"13"},"table_id":110}                                    | {"handle":{"c_d_id":"1","c_id":"1479","c_w_id":"18"},"table_id":110}                                    |                 110 |
|      1089 | {"handle":{"c_d_id":"7","c_id":"2326","c_w_id":"8"},"table_id":110}                                     | {"handle":{"c_d_id":"4","c_id":"1863","c_w_id":"13"},"table_id":110}                                    |                 110 |
|      1069 | {"handle":{"c_d_id":"7","c_id":"1066","c_w_id":"1"},"table_id":110}                                     | {"handle":{"c_d_id":"10","c_id":"2710","c_w_id":"3"},"table_id":110}                                    |                 110 |
|      1097 | {"table_id":112}                                                                                        | {"index_id":2,"index_vals":{"h_c_w_id":"16"},"table_id":112}                                            |                 112 |
|      1017 | {"index_id":2,"index_vals":{"h_c_w_id":"16"},"table_id":112}                                            | {"table_id":114}                                                                                        |                 112 |
|      1025 | {"table_id":114}                                                                                        | {"table_id":118}                                                                                        |                 114 |
|      1029 | {"handle":{"ol_d_id":"1","ol_number":"7","ol_o_id":"404","ol_w_id":"18"},"table_id":118}                | {"table_id":120}                                                                                        |                 118 |
|      1073 | {"handle":{"ol_d_id":"9","ol_number":"4","ol_o_id":"1820","ol_w_id":"5"},"table_id":118}                | {"handle":{"ol_d_id":"3","ol_number":"9","ol_o_id":"2730","ol_w_id":"8"},"table_id":118}                |                 118 |
|      1061 | {"table_id":118}                                                                                        | {"handle":{"ol_d_id":"5","ol_number":"3","ol_o_id":"967","ol_w_id":"3"},"table_id":118}                 |                 118 |
|      1065 | {"handle":{"ol_d_id":"5","ol_number":"3","ol_o_id":"967","ol_w_id":"3"},"table_id":118}                 | {"handle":{"ol_d_id":"9","ol_number":"4","ol_o_id":"1820","ol_w_id":"5"},"table_id":118}                |                 118 |
|      1093 | {"handle":{"ol_d_id":"2","ol_number":"10","ol_o_id":"1341","ol_w_id":"13"},"table_id":118}              | {"handle":{"ol_d_id":"6","ol_number":"7","ol_o_id":"2240","ol_w_id":"15"},"table_id":118}               |                 118 |
|      1081 | {"handle":{"ol_d_id":"3","ol_number":"9","ol_o_id":"2730","ol_w_id":"8"},"table_id":118}                | {"handle":{"ol_d_id":"8","ol_number":"9","ol_o_id":"624","ol_w_id":"10"},"table_id":118}                |                 118 |
|      1085 | {"handle":{"ol_d_id":"8","ol_number":"9","ol_o_id":"624","ol_w_id":"10"},"table_id":118}                | {"handle":{"ol_d_id":"2","ol_number":"10","ol_o_id":"1341","ol_w_id":"13"},"table_id":118}              |                 118 |
|      1105 | {"handle":{"ol_d_id":"6","ol_number":"7","ol_o_id":"2240","ol_w_id":"15"},"table_id":118}               | {"handle":{"ol_d_id":"1","ol_number":"7","ol_o_id":"404","ol_w_id":"18"},"table_id":118}                |                 118 |
|      1053 | {"handle":{"s_i_id":"49025","s_w_id":"12"},"table_id":120}                                              | {"handle":{"s_i_id":"23033","s_w_id":"15"},"table_id":120}                                              |                 120 |
|      1033 | {"handle":{"s_i_id":"42196","s_w_id":"18"},"table_id":120}                                              | {"index_id":2,"index_vals":"20, 10, 3000, 1859, 20, 10, 1859, ","table_id":124}                         |                 120 |
|      1049 | {"handle":{"s_i_id":"16535","s_w_id":"10"},"table_id":120}                                              | {"handle":{"s_i_id":"49025","s_w_id":"12"},"table_id":120}                                              |                 120 |
|      1041 | {"handle":{"s_i_id":"67971","s_w_id":"3"},"table_id":120}                                               | {"handle":{"s_i_id":"84050","s_w_id":"6"},"table_id":120}                                               |                 120 |
|      1037 | {"table_id":120}                                                                                        | {"handle":{"s_i_id":"67971","s_w_id":"3"},"table_id":120}                                               |                 120 |
|      1057 | {"handle":{"s_i_id":"23033","s_w_id":"15"},"table_id":120}                                              | {"handle":{"s_i_id":"42196","s_w_id":"18"},"table_id":120}                                              |                 120 |
|      1045 | {"handle":{"s_i_id":"84050","s_w_id":"6"},"table_id":120}                                               | {"handle":{"s_i_id":"16535","s_w_id":"10"},"table_id":120}                                              |                 120 |
|      2121 | {"index_id":2,"index_vals":"20, 10, 3000, 1859, 20, 10, 1859, ","table_id":124}                         | {"index_id":2,"index_vals":{"o_c_id":"1","o_d_id":"1","o_id":"2941","o_w_id":"1"},"table_id":1292}      |                 308 |
|      2141 | {"index_id":2,"index_vals":{"o_c_id":"1","o_d_id":"1","o_id":"2941","o_w_id":"1"},"table_id":1292}      | {"index_id":2,"index_vals":{"o_c_id":"3000","o_d_id":"10","o_id":"1859","o_w_id":"20"},"table_id":1292} |                1292 |
|      2133 | {"index_id":2,"index_vals":{"o_c_id":"3000","o_d_id":"10","o_id":"1859","o_w_id":"20"},"table_id":1292} | {"table_id":1298}                                                                                       |                1292 |
|      2169 | {"table_id":1298}                                                                                       | {"handle":{"o_d_id":"1","o_id":"1989","o_w_id":"10"},"table_id":1298}                                   |                1298 |
|      2165 | {"handle":{"o_d_id":"1","o_id":"1989","o_w_id":"10"},"table_id":1298}                                   | {"table_id":281474976710654}                                                                            |                1298 |
|       266 | {"table_id":281474976710654}                                                                            | {"table_id":281474976710655}                                                                            |     281474976710654 |
|        12 | {"table_id":281474976710655}                                                                            | 7800000000000000FB                                                                                      | 4611686018427387906 |
+-----------+---------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------+---------------------+
37 rows in set, 14 warnings (0.01 sec)

1 个赞