REGION_STATISTICS
The REGION_STATISTICS table provides detailed information about a region's statistics, including the total number of rows, disk size, and more. These statistics are approximate values.
NOTE
This table is not available on GreptimeCloud.
USE INFORMATION_SCHEMA;
DESC REGION_STATISTICS;
The output is as follows:
+--------------------------+--------+------+------+---------+---------------+
| Column                   | Type   | Key  | Null | Default | Semantic Type |
+--------------------------+--------+------+------+---------+---------------+
| region_id                | UInt64 |      | NO   |         | FIELD         |
| table_id                 | UInt32 |      | NO   |         | FIELD         |
| region_number            | UInt32 |      | NO   |         | FIELD         |
| region_rows              | UInt64 |      | YES  |         | FIELD         |
| written_bytes_since_open | UInt64 |      | YES  |         | FIELD         |
| disk_size                | UInt64 |      | YES  |         | FIELD         |
| memtable_size            | UInt64 |      | YES  |         | FIELD         |
| manifest_size            | UInt64 |      | YES  |         | FIELD         |
| sst_size                 | UInt64 |      | YES  |         | FIELD         |
| sst_num                  | UInt64 |      | YES  |         | FIELD         |
| index_size               | UInt64 |      | YES  |         | FIELD         |
| engine                   | String |      | YES  |         | FIELD         |
| region_role              | String |      | YES  |         | FIELD         |
+--------------------------+--------+------+------+---------+---------------+
Fields in the REGION_STATISTICS table are described as follows:
region_id: The ID of the Region.table_id: The ID of the table.region_number: The number of the region in the table.region_rows: The number of rows in the region.written_bytes_since_open: The number of bytes written to the region since the region was opened.disk_size: The total size of data files in the region, including data, index and metadata etc.memtable_size: The region's total size of memtables.manifest_size: The region's total size of manifest files.sst_num: The region's total number of SST files.sst_size: The region's total size of SST files.index_size: The region's total size of index files.engine: The engine type of the region,mitoormetric.region_role: The region's role,LeaderorFollower.
Retrieve a table's region statistics information as follows:
SELECT r.* FROM REGION_STATISTICS r LEFT JOIN TABLES t on r.table_id = t.table_id \
WHERE t.table_name = 'system_metrics';
Output:
+---------------+----------+---------------+-------------+--------------------------+-----------+---------------+---------------+----------+---------+------------+--------+-------------+
| region_id     | table_id | region_number | region_rows | written_bytes_since_open | disk_size | memtable_size | manifest_size | sst_size | sst_num | index_size | engine | region_role |
+---------------+----------+---------------+-------------+--------------------------+-----------+---------------+---------------+----------+---------+------------+--------+-------------+
| 4398046511104 |     1024 |             0 |           8 |                        0 |      4922 |             0 |          1338 |     3249 |       1 |        335 | mito   | Leader      |
+---------------+----------+---------------+-------------+--------------------------+-----------+---------------+---------------+----------+---------+------------+--------+-------------+