How to Query the Data Volume on a Specific TiDB Node

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: tidb 如何查询某一台的数据量

| username: 小跑跑泡

Now that TiKV has been deployed in a cluster, for example, I have deployed four nodes: tikv1, tikv2, tikv3, and tikv4. If I insert 100 million rows into the table ‘test’, how can I find out how much data is on the tikv1 server? Is there a way to query this through SQL?

| username: WalterWj | Original post link

You can check the space usage of tikv detail in the monitoring to see how much it has increased. If that doesn’t work, you can look at the estimated value in the system table, which is similar to how you query in MySQL, but it’s just an estimate.

| username: Jellybean | Original post link

You can check the data volume, used space, remaining space, and the number of leaders and regions for each store on each node in the TiKV Grafana monitoring panel.

| username: TiDBer_vfJBUcxl | Original post link

TiKV has two methods for distributed data storage: Hash and Range.

Hash: Hashes the key and selects the corresponding storage node based on the hash value.

Range: Divides the key into ranges, with a continuous segment of keys stored on a single storage node.

The Raft protocol ensures distributed data storage and data consistency through the Raft consensus algorithm, while also attempting to evenly distribute data across all nodes in the cluster.

| username: redgame | Original post link

I looked through my notebook, not sure if this can still be used:

SELECT TABLE_SCHEMA, TABLE_NAME, TABLE_ROWS
FROM information_schema.tables
WHERE TABLE_SCHEMA = 'your_database_name' AND TABLE_NAME = 'test';
| username: zhanggame1 | Original post link

You can’t check the TiKV data volume with this either.

| username: tidb菜鸟一只 | Original post link

You want to check how much data a specific table has on each TiKV node, right?

| username: cy6301567 | Original post link

This is good, give it a try.

| username: Jellybean | Original post link

TiKV-Details Panel → Cluster

  • Store size: The size of the storage space used by each TiKV instance
  • Available size: The size of the available storage space for each TiKV instance
  • Capacity size: The storage capacity size of each TiKV instance
  • Leader: The number of leaders for each TiKV instance
  • Region: The number of Regions for each TiKV instance
| username: Kongdom | Original post link

It should only be able to check the data size, not which record is on which TiKV node, right?

| username: yiduoyunQ | Original post link

How to estimate the size of a table in TiDB? Try modifying the SQL a bit.

| username: zhanggame1 | Original post link

You can check the record location. If the primary key is int or bigint, it is very convenient. Using show table xxx regions allows you to see which region the data is on.