查看表数据存储、分布在哪些tikv节点上

不显示tiflash节点加r.IS_LEARNER=0

SELECT
  rs.`DB_NAME`,
  rs.`TABLE_NAME`,
  s.ADDRESS,
  r.`IS_LEADER`,
  r.`IS_LEARNER`,
  COUNT(r.REGION_ID)
FROM
  INFORMATION_SCHEMA.TIKV_REGION_PEERS r,
  INFORMATION_SCHEMA.TIKV_STORE_STATUS s,
  INFORMATION_SCHEMA.tikv_region_status rs
WHERE r.STORE_ID = s.STORE_ID
  AND r.`REGION_ID` = rs.`REGION_ID`
  AND rs.`DB_NAME` = 'xxx'
  AND rs.`TABLE_NAME` = 'tablename'
  AND r.`IS_LEARNER`=0
GROUP BY rs.`DB_NAME`,
  rs.`TABLE_NAME`,
  s.`ADDRESS`,
  r.`IS_LEADER`,
  r.`IS_LEARNER`
  ORDER BY r.`IS_LEADER`;

is_leader可以看是否leader region

1 个赞