TIKV_REGION_STATUS

The TIKV_REGION_STATUS table shows some basic information of TiKV Regions via PD’s API, like the Region ID, starting and ending key-values, and read and write traffic.

TIKV_REGION_STATUS - 图1

Note

This table is not available on TiDB Serverless clusters.

  1. USE INFORMATION_SCHEMA;
  2. DESC TIKV_REGION_STATUS;

The output is as follows:

  1. +---------------------------+-------------+------+------+---------+-------+
  2. | Field | Type | Null | Key | Default | Extra |
  3. +---------------------------+-------------+------+------+---------+-------+
  4. | REGION_ID | bigint(21) | YES | | NULL | |
  5. | START_KEY | text | YES | | NULL | |
  6. | END_KEY | text | YES | | NULL | |
  7. | TABLE_ID | bigint(21) | YES | | NULL | |
  8. | DB_NAME | varchar(64) | YES | | NULL | |
  9. | TABLE_NAME | varchar(64) | YES | | NULL | |
  10. | IS_INDEX | tinyint(1) | NO | | 0 | |
  11. | INDEX_ID | bigint(21) | YES | | NULL | |
  12. | INDEX_NAME | varchar(64) | YES | | NULL | |
  13. | IS_PARTITION | tinyint(1) | NO | | 0 | |
  14. | PARTITION_ID | bigint(21) | YES | | NULL | |
  15. | PARTITION_NAME | varchar(64) | YES | | NULL | |
  16. | EPOCH_CONF_VER | bigint(21) | YES | | NULL | |
  17. | EPOCH_VERSION | bigint(21) | YES | | NULL | |
  18. | WRITTEN_BYTES | bigint(21) | YES | | NULL | |
  19. | READ_BYTES | bigint(21) | YES | | NULL | |
  20. | APPROXIMATE_SIZE | bigint(21) | YES | | NULL | |
  21. | APPROXIMATE_KEYS | bigint(21) | YES | | NULL | |
  22. | REPLICATIONSTATUS_STATE | varchar(64) | YES | | NULL | |
  23. | REPLICATIONSTATUS_STATEID | bigint(21) | YES | | NULL | |
  24. +---------------------------+-------------+------+------+---------+-------+
  25. 20 rows in set (0.00 sec)

The descriptions of the columns in the TIKV_REGION_STATUS table are as follows:

  • REGION_ID: The ID of the Region.
  • START_KEY: The value of the start key of the Region.
  • END_KEY: The value of the end key of the Region.
  • TABLE_ID: The ID of the table to which the Region belongs.
  • DB_NAME: The name of the database to which TABLE_ID belongs.
  • TABLE_NAME: The name of the table to which the Region belongs.
  • IS_INDEX: Whether the Region data is an index. 0 means that it is not an index, while 1 means that it is an index. If the current Region contains both table data and index data, there will be multiple rows of records, and IS_INDEX is 0 and 1 respectively.
  • INDEX_ID: The ID of the index to which the Region belongs. If IS_INDEX is 0, the value of this column is NULL.
  • INDEX_NAME: The name of the index to which the Region belongs. If IS_INDEX is 0, the value of this column is NULL.
  • IS_PARTITION: Whether the table to which the Region belongs is partitioned.
  • PARTITION_ID: If the table to which the Region belongs is partitioned, this column displays the ID of the partition to which the Region belongs.
  • PARTITION_NAME: If the table to which the Region belongs is partitioned, this column displays the name of the partition to which the Region belongs.
  • EPOCH_CONF_VER: The version number of the Region configuration. The version number increases when a peer is added or removed.
  • EPOCH_VERSION: The current version number of the Region. The version number increases when the Region is split or merged.
  • WRITTEN_BYTES: The amount of data (bytes) written to the Region.
  • READ_BYTES: The amount of data (bytes) that has been read from the Region.
  • APPROXIMATE_SIZE: The approximate data size (MB) of the Region.
  • APPROXIMATE_KEYS: The approximate number of keys in the Region.
  • REPLICATIONSTATUS_STATE: The current replication status of the Region. The status might be UNKNOWN, SIMPLE_MAJORITY, or INTEGRITY_OVER_LABEL.
  • REPLICATIONSTATUS_STATEID: The identifier corresponding to REPLICATIONSTATUS_STATE.

Also, you can implement the top confver, top read and top write operations in pd-ctl via the ORDER BY X LIMIT Y operation on the EPOCH_CONF_VER, WRITTEN_BYTES and READ_BYTES columns.

You can query the top 3 Regions with the most write data using the following SQL statement:

  1. SELECT * FROM tikv_region_status ORDER BY written_bytes DESC LIMIT 3;