title | summary |
---|---|
TIKV_REGION_PEERS |
Learn the `TIKV_REGION_PEERS` information_schema table. |
The TIKV_REGION_PEERS
table shows detailed information of a single Region node in TiKV, such as whether it is a learner or leader.
{{< copyable "sql" >}}
USE information_schema;
DESC tikv_region_peers;
+--------------+-------------+------+------+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------------+-------------+------+------+---------+-------+
| REGION_ID | bigint(21) | YES | | NULL | |
| PEER_ID | bigint(21) | YES | | NULL | |
| STORE_ID | bigint(21) | YES | | NULL | |
| IS_LEARNER | tinyint(1) | NO | | 0 | |
| IS_LEADER | tinyint(1) | NO | | 0 | |
| STATUS | varchar(10) | YES | | 0 | |
| DOWN_SECONDS | bigint(21) | YES | | 0 | |
+--------------+-------------+------+------+---------+-------+
7 rows in set (0.01 sec)
For example, you can query the specific TiKV addresses for the top 3 Regions with the maximum value of WRITTEN_BYTES
using the following SQL statement:
SELECT
address,
tikv.address,
region.region_id
FROM
tikv_store_status tikv,
tikv_region_peers peer,
(SELECT * FROM tikv_region_status ORDER BY written_bytes DESC LIMIT 3) region
WHERE
region.region_id = peer.region_id
AND peer.is_leader = 1
AND peer.store_id = tikv.store_id;
Fields in the TIKV_REGION_PEERS
table are described as follows:
- REGION_ID: The Region ID.
- PEER_ID: The ID of the Region peer.
- STORE_ID: The ID of the TiKV store where the Region is located.
- IS_LEARNER: Whether the peer is learner.
- IS_LEADER: Whether the peer is leader.
- STATUS: The statuses of a peer:
- PENDING: Temporarily unavailable.
- DOWN: Offline and converted. This peer no longer provides service.
- NORMAL: Running normally.
- DOWN_SECONDS: The duration of being offline, in seconds.