Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.Original topic: 如何将 keys 均匀分布在各个region ?
|
username: TiDBer_rdb3y58G
The final result shows that the keys are not evenly distributed across the regions.
select count(1) from customer2; -- 25000
select min(_tidb_rowid), max(_tidb_rowid) from customer2; -- 8646911284551352321, 8646911284551377320
split table customer2 between (8646911284551352321) and (8646911284551377320) regions 16;
SELECT
c.address,
sum(APPROXIMATE_KEYS),
count(1)
FROM
INFORMATION_SCHEMA.TIKV_REGION_STATUS s
JOIN INFORMATION_SCHEMA.TIKV_REGION_PEERS p ON s.REGION_ID = p.REGION_ID
JOIN INFORMATION_SCHEMA.TIKV_STORE_STATUS c ON p.store_id = c.store_id
WHERE
TABLE_NAME = 'customer2'
AND p.is_leader = 1
AND APPROXIMATE_KEYS > 0
AND is_index = 0
GROUP BY c.address
ORDER BY 1;
+----------------------+-----------------------+----------+
| address | sum(APPROXIMATE_KEYS) | count(1) |
+----------------------+-----------------------+----------+
| 192.168.145.82:20160 | 8597 | 6 |
| 192.168.145.83:20160 | 19778 | 6 |
| 192.168.145.84:20160 | 8170 | 6 |
+----------------------+-----------------------+----------+
3 rows in set (0.10 sec)