Skip to content

Commit

Permalink
docs: adds region_statistics refernece
Browse files Browse the repository at this point in the history
  • Loading branch information
killme2008 committed Nov 5, 2024
1 parent 34cd39f commit 8c22968
Show file tree
Hide file tree
Showing 7 changed files with 138 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/reference/sql/information-schema/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ There is still lots of work to do for `INFORMATION_SCHEMA`. The tracking [issue]
| --- | --- |
| [`BUILD_INFO`](./build-info.md) | Provides the system build info. |
| [`REGION_PEERS`](./region-peers.md) | Provides details about where regions are stored. |
| [`REGION_STATISTICS`](./region-statistics.md) | Provides details about region statistics info, such as disk size, etc. |
| [`RUNTIME_METRICS`](./runtime-metrics.md)| Provides the system runtime metrics.|
| [`CLUSTER_INFO`](./cluster-info.md)| Provides the topology information of the cluster.|
| [`FLOWS`](./flows.md) | Provides the flow information.|
Expand Down
63 changes: 63 additions & 0 deletions docs/reference/sql/information-schema/region-statistics.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# 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.

:::tip NOTE
This table is not available on [GreptimeCloud](https://greptime.cloud/).
:::

```sql
USE INFORMATION_SCHEMA;
DESC REGION_STATISTICS;
```

The output is as follows:

```sql
+---------------+--------+------+------+---------+---------------+
| 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 |
| disk_size | UInt64 | | YES | | FIELD |
| memtable_size | UInt64 | | YES | | FIELD |
| manifest_size | UInt64 | | YES | | FIELD |
| sst_size | 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.
- `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_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, `mito` or `metric`.
- `region_role`: The region's role, `Leader` or `Follower`.


Retrieve a table's region statistics information as follows:

```sql
SELECT r.* FROM REGION_STATISTICS r LEFT JOIN TABLES t on r.table_id = t.table_id WHERE t.table_name = 'system_metrics';
```


Output:
```sql
+---------------+----------+---------------+-------------+-----------+---------------+---------------+----------+------------+--------+-------------+
| region_id | table_id | region_number | region_rows | disk_size | memtable_size | manifest_size | sst_size | index_size | engine | region_role |
+---------------+----------+---------------+-------------+-----------+---------------+---------------+----------+------------+--------+-------------+
| 4398046511104 | 1024 | 0 | 8 | 4922 | 0 | 1338 | 3249 | 335 | mito | Leader |
+---------------+----------+---------------+-------------+-----------+---------------+---------------+----------+------------+--------+-------------+
```
6 changes: 5 additions & 1 deletion docs/reference/sql/information-schema/tables.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,12 @@ The description of columns in the `TABLES` table is as follows:
- `TEMPORARY` for a temporary result set.
- `VIEW` for a view.
- `table_id`: The ID of the table.
- `data_length`: The total length of the table's SST files in bytes, which is an approximate value.
- `index_length`: The total length of the table's index files in bytes, which is an approximate value.
- `table_rows`: The table's total row number, which is an approximate value.
- `avg_row_length`: The average row length in bytes, which is an approximate value.
- `engine`: The storage engine of the table used.
- `version`: Version. The value is `11` by default.
- `create_time`: The table created timestamp.
- `table_comment`: The table comment.
- Other columns such as `table_rows`, `row_format` etc. are not supported, just for compatibility with MySQL. GreptimeDB may support some of them in the future.
- Other columns such as `auto_increment`, `row_format` etc. are not supported, just for compatibility with MySQL. GreptimeDB may support some of them in the future.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
| --- | --- |
| [`BUILD_INFO`](./build-info.md) | 提供了系统构建的信息。 |
| [`REGION_PEERS`](./region-peers.md) | 提供了表的 Region 存储的详细信息。 |
| [`REGION_STATISTICS`](./region-statistics.md) | 提供 Region 的详细统计信息,例如行数等。 |
| [`RUNTIME_METRICS`](./runtime-metrics.md)| 提供了系统运行时指标。|
| [`CLUSTER_INFO`](./cluster-info.md)| 提供了集群的节点拓扑信息。|
| [`FLOWS`](./flows.md) | 提供 Flow 相关信息。|
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# REGION_STATISTICS

`REGION_STATISTICS` 表提供了关于某个 Region 统计信息的详细数据,包括总行数、磁盘大小等。这些统计信息都是近似值。

:::tip NOTE
此表在 [GreptimeCloud](https://greptime.cloud/) 中不可用。
:::

```sql
USE INFORMATION_SCHEMA;
DESC REGION_STATISTICS;
```

输出如下:

```sql
+---------------+--------+------+------+---------+---------------+
| 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 |
| disk_size | UInt64 | | YES | | FIELD |
| memtable_size | UInt64 | | YES | | FIELD |
| manifest_size | UInt64 | | YES | | FIELD |
| sst_size | UInt64 | | YES | | FIELD |
| index_size | UInt64 | | YES | | FIELD |
| engine | String | | YES | | FIELD |
| region_role | String | | YES | | FIELD |
+---------------+--------+------+------+---------+---------------+
```

`REGION_STATISTICS` 表中的字段描述如下:

- `region_id`: Region 的 ID。
- `table_id`: 表的 ID。
- `region_number`: Region 在表中的编号。
- `region_rows`: Region 中的记录行数。
- `disk_size`: Region 中数据文件的总大小,包括数据、索引及元信息等。
- `memtable_size`: Region 中内存 memtables 的总大小。
- `manifest_size`: Region 中元信息 manifest 文件的总大小。
- `sst_size`: Region 中 SST 文件的总大小。
- `index_size`: Region 中索引文件的总大小。
- `engine`: Region 的引擎类型,可以是 `mito``metric`
- `region_role`: Region 的角色,可以是 `Leader``Follower`

获取某张表的 Region 统计信息如下:

```sql
SELECT r.* FROM REGION_STATISTICS r LEFT JOIN TABLES t on r.table_id = t.table_id WHERE t.table_name = 'system_metrics';
```

输出:
```sql
+---------------+----------+---------------+-------------+-----------+---------------+---------------+----------+------------+--------+-------------+
| region_id | table_id | region_number | region_rows | disk_size | memtable_size | manifest_size | sst_size | index_size | engine | region_role |
+---------------+----------+---------------+-------------+-----------+---------------+---------------+----------+------------+--------+-------------+
| 4398046511104 | 1024 | 0 | 8 | 4922 | 0 | 1338 | 3249 | 335 | mito | Leader |
+---------------+----------+---------------+-------------+-----------+---------------+---------------+----------+------------+--------+-------------+
```
```
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ SHOW TABLES
- `TEMPORARY`:临时结果集
- `VIEW`:视图表
- `table_id`:表 ID。
- `data_length`: 表中 SST 文件的总长度(以字节为单位),近似值。
- `index_length`: 表中索引文件的总长度(以字节为单位),近似值。
- `table_rows`: 表中总的记录行数,近似值。
- `avg_row_length`: 表中记录的平均大小(以字节为单位),近似值。
- `engine`:该表使用的存储引擎。
- `version`: 版本。固定值为 `11`
- `create_time`: 表创建的时间戳。
Expand Down
3 changes: 2 additions & 1 deletion sidebars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ const sidebars: SidebarsConfig = {
items: ['enterprise/deployments/authentication',],
},
{
type: 'category',
type: 'category',
label: 'Administration',
items: [
{
Expand Down Expand Up @@ -393,6 +393,7 @@ const sidebars: SidebarsConfig = {
'reference/sql/information-schema/views',
'reference/sql/information-schema/flows',
'reference/sql/information-schema/region-peers',
'reference/sql/information-schema/region-statistics',
'reference/sql/information-schema/runtime-metrics',
'reference/sql/information-schema/cluster-info',
],
Expand Down

0 comments on commit 8c22968

Please sign in to comment.