Skip to content

Commit

Permalink
feat: adds admin reference and updated some links (#1168)
Browse files Browse the repository at this point in the history
Co-authored-by: Yiran <[email protected]>
  • Loading branch information
killme2008 and nicecui authored Sep 5, 2024
1 parent 0efd9fa commit 89168c4
Show file tree
Hide file tree
Showing 17 changed files with 103 additions and 65 deletions.
8 changes: 2 additions & 6 deletions docs/faq-and-others/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ Common use cases for time-series database include but are not limited to the fol

Please refer to [features that you concern](/user-guide/concepts/features-that-you-concern.md).

### How is GreptimeDB's performance compared to other solutions?

GreptimeDB has released v0.8, with functionalities set to improve progressively. For detailed TSBS test results, refer to the link [here](https://github.com/GreptimeTeam/greptimedb/blob/main/docs/benchmarks/tsbs/v0.8.0.md).

### How is the performance of GreptimeDB when used for non-time-series DB tables?

GreptimeDB supports SQL and can deal with non-time-series data, especially efficient for high concurrent and throughput data writing. However, we develop GreptimeDB for a specific domain (time-series scenarios), and it doesn't support transactions and can't delete data efficiently.
Expand Down Expand Up @@ -142,10 +138,10 @@ Of course, please use the `compact_table` function:

```sql
-- Schedule a compaction for table test --
select compact_table("test");
ADMIN compact_table("test");
```

There are many [administration functions](/reference/sql/functions/overview.md#admin-functions) for database management.
There are many [administration functions](/reference/sql/admin.md#admin-functions) for database management.

### Can GreptimeDB be used to store logs?

Expand Down
29 changes: 29 additions & 0 deletions docs/reference/sql/admin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# ADMIN

`ADMIN` is used to run administration functions.

```sql
ADMIN function(arg1, arg2, ...)
```


## Admin Functions

GreptimeDB provides some administration functions to manage the database and data:

* `flush_table(table_name)` to flush a table's memtables into SST file by table name.
* `flush_region(region_id)` to flush a region's memtables into SST file by region id. Find the region id through [PARTITIONS](./information-schema/partitions.md) table.
* `compact_table(table_name, [type], [options])` to schedule a compaction task for a table by table name, read [compaction](/user-guide/operations/compaction.md#strict-window-compaction-strategy-swcs-and-manual-compaction) for more details.
* `compact_region(region_id)` to schedule a compaction task for a region by region id.
* `migrate_region(region_id, from_peer, to_peer, [timeout])` to migrate regions between datanodes, please read the [Region Migration](/user-guide/operations/region-migration.md).
* `procedure_state(procedure_id)` to query a procedure state by its id.
* `flush_flow(flow_name)` to flush a flow's output into the sink table.

For example:
```sql
-- Flush the table test --
admin flush_table("test");

-- Schedule a compaction for table test --
admin compact_table("test");
```
21 changes: 2 additions & 19 deletions docs/reference/sql/functions/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Where the `datatype` can be any valid Arrow data type in this [list](https://arr
DataFusion [String Function](./df-functions.md#string-functions).GreptimeDB provides:
* `matches(expression, pattern)` for full text search.

<!-- TODO: link to full-text searching user guide. -->
For details, read the [Query Logs](/user-guide/logs/query-logs.md).

### Math Functions

Expand Down Expand Up @@ -247,21 +247,4 @@ select database();

### Admin Functions

GreptimeDB provides some administration functions to manage the database and data:

* `flush_table(table_name)` to flush a table's memtables into SST file by table name.
* `flush_region(region_id)` to flush a region's memtables into SST file by region id. Find the region id through [PARTITIONS](../information-schema/partitions.md) table.
* `compact_table(table_name)` to schedule a compaction task for a table by table name.
* `compact_region(region_id)` to schedule a compaction task for a region by region id.
* `migrate_region(region_id, from_peer, to_peer, [timeout])` to migrate regions between datanodes, please read the [Region Migration](/user-guide/operations/region-migration.md).
* `procedure_state(procedure_id)` to query a procedure state by its id.
* `flush_flow(flow_name)` to flush a flow's output into the sink table.

For example:
```sql
-- Flush the table test --
admin flush_table("test");

-- Schedule a compaction for table test --
admin compact_table("test");
```
GreptimeDB provides `ADMIN` statement to run the administration functions, please refer to [ADMIN](.(/reference/sql/admin.md) reference.
1 change: 1 addition & 0 deletions docs/reference/sql/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@
* [ALTER](./alter.md)
* [EXPLAIN](./explain.md)
* [Functions](./functions/overview.md)
* [ADMIN](./admin.md)
* [ANSI Compatibility](./compatibility.md)
* [INFORMATION_SCHEMA](./information-schema/overview.md)
10 changes: 10 additions & 0 deletions docs/user-guide/concepts/features-that-you-concern.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ The data can be stored in cost-effective cloud storage services such as AWS S3 o

GreptimeDB also offers a fully-managed cloud service [GreptimeCloud](https://greptime.com/product/cloud) to help you manage data in the cloud.

### How is GreptimeDB's performance compared to other solutions?

Please read the performance benchmark reports:

* [GreptimeDB vs. InfluxDB](https://greptime.com/blogs/2024-08-07-performance-benchmark)
* [GreptimeDB vs. Grafana Mimir](https://greptime.com/blogs/2024-08-02-datanode-benchmark)
* [GreptimeDB vs. ClickHouse vs. ElasticSearch](https://greptime.com/blogs/2024-08-22-log-benchmark)
* [GreptimeDB vs. SQLite](https://greptime.com/blogs/2024-08-30-sqlite)


## Does GreptimeDB have disaster recovery solutions?

Yes. Please refer to [disaster recovery](/user-guide/operations/disaster-recovery/overview.md).
4 changes: 2 additions & 2 deletions docs/user-guide/operations/admin.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ The `INFORMATION_SCHEMA` database provides access to system metadata, such as th

* [The Storage Location](/user-guide/concepts/storage-location.md).
* Cluster Failover for GreptimeDB by [Setting Remote WAL](./remote-wal/quick-start.md).
* [Flush and Compaction for Table & Region](/reference/sql/functions/overview.md#admin-functions).
* [Flush and Compaction for Table & Region](/reference/sql/admin.md#admin-functions).
* Partition the table by regions, read the [Table Sharding](/contributor-guide/frontend/table-sharding.md) reference.
* [Migrate the Region](./region-migration.md) for Load Balance.
* [Expire Data by Setting TTL](/user-guide/concepts/features-that-you-concern.md#can-i-set-ttl-or-retention-policy-for-different-tables-or-measurements).

## Best Practices

TODO
* [Performance Tuning Tips](/user-guide/operations/performance-tuning-tips.md)
6 changes: 3 additions & 3 deletions docs/user-guide/operations/compaction.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ WITH (
Unlike TWCS, which assigns one window per SST file based on their maximum timestamps, SWCS assigns SST files to **all** overlapping windows. Consequently, a single SST file may be included in multiple compaction outputs, as its name suggests. Due to its high read amplification during compaction, SWCS is not the default compaction strategy. However, it is useful when you need to manually trigger compaction to reorganize the layout of SST files—especially if an individual SST file spans a large time range that significantly slows down queries. GreptimeDB offers a simple SQL function for triggering compaction:

```sql
SELECT COMPACT_TABLE(
ADMIN COMPACT_TABLE(
<table_name>,
<strategy_name>,
[<strategy_parameters>]
Expand All @@ -117,14 +117,14 @@ The `<strategy_name>` parameter can be either `twcs` or `swcs` (case insensitive
For the `swcs` strategy, the `<strategy_parameters>` specify the window size (in seconds) for splitting SST files. For example:

```sql
SELECT COMPACT_TABLE(
ADMIN COMPACT_TABLE(
"monitor",
"swcs",
"3600"
);

+--------------------------------------------------------------------+
| compact_table(Utf8("monitor"),Utf8("swcs"),Utf8("3600")) |
| ADMIN compact_table(Utf8("monitor"),Utf8("swcs"),Utf8("3600")) |
+--------------------------------------------------------------------+
| 0 |
+--------------------------------------------------------------------+
Expand Down
6 changes: 3 additions & 3 deletions docs/user-guide/operations/region-migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ Remember, if you deploy the cluster via the GreptimeDB operator, the `peer_id` o
Finally, you can do a Region migration request via the following SQL:

```sql
select migrate_region(4398046511104, 1, 2, 60);
ADMIN migrate_region(4398046511104, 1, 2, 60);
```

The parameters of `migrate_region`

```sql
select migrate_region(region_id, from_peer_id, to_peer_id, replay_timeout);
ADMIN migrate_region(region_id, from_peer_id, to_peer_id, replay_timeout);
```

| Option | Description | Required | |
Expand All @@ -66,7 +66,7 @@ select migrate_region(region_id, from_peer_id, to_peer_id, replay_timeout);
The `migrate_region` function returns the procedure id that executes the migration, queries the procedure state by it:

```sql
select procedure_state('538b7476-9f79-4e50-aa9c-b1de90710839')
ADMIN procedure_state('538b7476-9f79-4e50-aa9c-b1de90710839')
```

If it's done, outputs the state in JSON:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ Common use cases for time-series database include but are not limited to the fol

Please refer to [features that you concern](/user-guide/concepts/features-that-you-concern.md).

### How is GreptimeDB's performance compared to other solutions?

GreptimeDB has released v0.8, with functionalities set to improve progressively. For detailed TSBS test results, refer to the link [here](https://github.com/GreptimeTeam/greptimedb/blob/main/docs/benchmarks/tsbs/v0.8.0.md).

### How is the performance of GreptimeDB when used for non-time-series DB tables?

Expand Down Expand Up @@ -142,10 +139,10 @@ Of course, please use the `compact_table` function:

```sql
-- Schedule a compaction for table test --
select compact_table("test");
ADMIN compact_table("test");
```

There are many [administration functions](/reference/sql/functions/overview.md#admin-functions) for database management.
There are many [administration functions](/reference/sql/admin.md#admin-functions) for database management.

### Can GreptimeDB be used to store logs?

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# ADMIN

`ADMIN` 语句用于运行管理函数:

```sql
ADMIN function(arg1, arg2, ...)
```

## 管理函数

GreptimeDB 提供了一些管理函数来管理数据库和数据:

* `flush_table(table_name)` 根据表名将表的 Memtable 刷新到 SST 文件中。
* `flush_region(region_id)` 根据 Region ID 将 Region 的 Memtable 刷新到 SST 文件中。通过 [PARTITIONS](./information-schema/partitions.md) 表查找 Region ID。
* `compact_table(table_name, [type], [options])` 为表启动一个 compaction 任务,详细信息请阅读 [compaction](/user-guide/operations/compaction.md#严格窗口压缩策略swcs和手动压缩)
* `compact_region(region_id)` 为 Region 启动一个 compaction 任务。
* `migrate_region(region_id, from_peer, to_peer, [timeout])` 在 Datanode 之间迁移 Region,请阅读 [Region Migration](/user-guide/operations/region-migration.md)
* `procedure_state(procedure_id)` 根据 ID 查询 Procedure 状态。
* `flush_flow(flow_name)` 将 Flow 的输出刷新到目标接收表。

例如:
```sql
-- 刷新表 test --
admin flush_table("test");

-- 为表 test 启动 compaction 任务 --
admin compact_table("test");
```
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ arrow_cast(expression, datatype)
DataFusion [字符串函数](./df-functions.md#string-functions)。GreptimeDB 提供:
* `matches(expression, pattern)` 用于全文检索。

TODO:链接到全文检索用户指南
阅读[查询日志](/user-guide/logs/query-logs.md)文档获取更多详情

### 数学函数

Expand Down Expand Up @@ -240,21 +240,4 @@ select database();

### 管理函数

GreptimeDB 提供一些管理数据库和数据的函数:

* `flush_table(table_name)` 通过表名将表的内存表刷写到 SST 文件。
* `flush_region(region_id)` 通过 Region Id 将 Region 的内存表刷写到 SST 文件。可以通过 [PARTITIONS](../information-schema/partitions.md) 表查找一张表的所有 Region Id。
* `compact_table(table_name)` 通过表名为表发起compaction 任务。
* `compact_region(region_id)` 通过 Region Id 为 Region 发起 compaction 任务。
* `migrate_region(region_id, from_peer, to_peer, [timeout])` 在 Datanode 之间迁移 Region,请阅读 [ Region迁移](/user-guide/operations/region-migration)
* `procedure_state(procedure_id)` 通过 Procedure Id 查询 Procedure 状态。
* `flush_flow(flow_name)` 通过 Flow 名称将 Flow 的输出刷写到结果表。

例如:
```sql
-- 刷新表 test --
admin flush_table("test");

-- 为表 test 安排压缩任务 --
admin compact_table("test".md);
```
GreptimeDB 提供了 `ADMIN` 语句来执行管理函数,请阅读 [ADMIN](/reference/sql/admin.md) 文档。
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@
* [ALTER](./alter.md)
* [EXPLAIN](./explain.md)
* [Functions](./functions/overview.md)
* [ADMIN](./admin.md)
* [ANSI Compatibility](./compatibility.md)
* [INFORMATION_SCHEMA](./information-schema/overview.md)
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ GreptimeDB 通过以下方式解决这个问题:

GreptimeDB 还提供一个完全托管的云服务 [GreptimeCloud](https://greptime.cn/product/cloud) 来帮助您管理云中的数据。

## GreptimeDB 对比其他存储或时序数据库的性能如何?

请阅读以下性能报告:

* [GreptimeDB vs. InfluxDB](https://greptime.cn/blogs/2024-08-08-report)
* [GreptimeDB vs. Grafana Mimir](https://greptime.cn/blogs/2024-08-01-grafana)
* [GreptimeDB vs. ClickHouse vs. ElasticSearch](https://greptime.cn/blogs/2024-08-21-report)
* [GreptimeDB vs. SQLite](https://greptime.cn/blogs/2024-08-30-sqlite)

## GreptimeDB 有灾难恢复解决方案吗?

有的,请参阅[灾难恢复文档](/user-guide/operations/disaster-recovery/overview.md)
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ ORDER BY datanode_id ASC

* [存储位置说明](/user-guide/concepts/storage-location.md)
* 通过 [设置Remote WAL](./remote-wal/quick-start.md) 实现 GreptimeDB 的集群容灾。
* [Table 和 Region 的 Flush 和 Compaction](/reference/sql/functions/overview.md#admin-functions)
* [Table 和 Region 的 Flush 和 Compaction](/reference/sql/admin.md##管理函数)
* 通过 Region 对表进行分区,请阅读 [表的分片](/contributor-guide/frontend/table-sharding.md) 参考。
* [迁移 Region](./region-migration.md) 以实现负载均衡。
* [通过设置 TTL 过期数据](/user-guide/concepts/features-that-you-concern.md#can-i-set-ttl-or-retention-policy-for-different-tables-or-measurements)

## 最佳实践

TODO
* [性能调优技巧](/user-guide/operations/performance-tuning-tips.md)
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ WITH (
与 TWCS 根据 SST 文件的最大时间戳为每个窗口分配一个 SST 文件不同的是,严格窗口策略(SWCS)将 SST 文件分配给**所有与此文件的时间范围重叠**的窗口,正如其名称所示。因此,一个 SST 文件可能会包含在多个压缩输出中。由于其在压缩期间的高读取放大率,SWCS 并不是默认的压缩策略。然而,当用户需要手动触发压缩以重新组织 SST 文件布局时,它是有用的,特别是当单个 SST 文件跨越较大的时间范围而显著减慢查询速度时。GreptimeDB 提供了一个简单的 SQL 函数来触发手动压缩:

```sql
SELECT COMPACT_TABLE(
ADMIN COMPACT_TABLE(
<table_name>,
<strategy_name>,
[<strategy_parameters>]
Expand All @@ -116,14 +116,14 @@ SELECT COMPACT_TABLE(
对于 `swcs` 策略, `<strategy_parameters>` 指定用于拆分 SST 文件的窗口大小(以秒为单位)。例如:

```sql
SELECT COMPACT_TABLE(
ADMIN COMPACT_TABLE(
"monitor",
"swcs",
"3600"
);

+--------------------------------------------------------------------+
| compact_table(Utf8("monitor"),Utf8("swcs"),Utf8("3600")) |
| ADMIN compact_table(Utf8("monitor"),Utf8("swcs"),Utf8("3600")) |
+--------------------------------------------------------------------+
| 0 |
+--------------------------------------------------------------------+
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ on a.greptime_partition_id = b.region_id where a.table_name='migration_target' o
最后,你可以通过以下 SQL 请求发起 Region 迁移请求:

```sql
select migrate_region(4398046511104, 1, 2, 60);
ADMIN migrate_region(4398046511104, 1, 2, 60);
```

`migrate_region` 参数说明:

```sql
select migrate_region(region_id, from_peer_id, to_peer_id, replay_timeout);
ADMIN migrate_region(region_id, from_peer_id, to_peer_id, replay_timeout);
```

| Option | Description | Required | |
Expand All @@ -65,7 +65,7 @@ select migrate_region(region_id, from_peer_id, to_peer_id, replay_timeout);
`migrate_region` 函数将返回执行迁移的 Procedure Id,可以通过它查询过程状态:

```sql
select procedure_state('538b7476-9f79-4e50-aa9c-b1de90710839')
ADMIN procedure_state('538b7476-9f79-4e50-aa9c-b1de90710839')
```

如果顺利完成,将输出 JSON 格式的状态:
Expand Down
1 change: 1 addition & 0 deletions sidebars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ const sidebars: SidebarsConfig = {
'reference/sql/alter',
'reference/sql/explain',
{ type: 'category', label: 'Functions', items: ['reference/sql/functions/overview', 'reference/sql/functions/df-functions'] },
'reference/sql/admin',
'reference/sql/compatibility',
{
type: 'category',
Expand Down

0 comments on commit 89168c4

Please sign in to comment.