Skip to content

Commit

Permalink
feat: adds admin functions
Browse files Browse the repository at this point in the history
  • Loading branch information
killme2008 committed May 18, 2024
1 parent 101530a commit e03454d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
22 changes: 22 additions & 0 deletions docs/nightly/en/reference/sql/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,28 @@ Where the `datatype` can be any valid Arrow data type in this [list](https://arr

Please refer to [API documentation](https://greptimedb.rs/script/python/rspython/builtins/greptime_builtin/index.html#functions)

### 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 [REGION_PEERS](./information-schema/region-peers.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).
* `procedure_state(procedure_id)` to query a procedure state by its id.

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

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



## Time and Date

### `date_trunc`
Expand Down
7 changes: 4 additions & 3 deletions docs/nightly/en/user-guide/operations/admin.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,21 @@ This document addresses strategies and practices used in the operation of Grepti

* [Installation](/getting-started/installation/overview.md) for GreptimeDB and the [g-t-control](./gtctl.md) command line tool.
* Database Configuration, please read the [Configuration](./configuration.md) reference.
* [Monitoring](./monitoring.md) for GreptimeDB.
* [Monitoring](./monitoring.md) and [Tracing](./tracing.md) for GreptimeDB.
* GreptimeDB [Backup & Restore methods](./back-up-\&-restore-data.md).

### Runtime information

* Find the topology information of the cluster though [CLUSTER_INFO](/reference/sql/information-schema/cluster-info.md) table.
* Find the table regions distribution though [REGION_PEERS](/reference/sql/information-schema/region-peers.md) table.

`INFORMATION_SCHEMA` provides access to system metadata, such as the name of a database or table, the data type of a column, etc. Please read the [reference](/reference/sql/information-schema/overview).
`INFORMATION_SCHEMA` provides access to system metadata, such as the name of a database or table, the data type of a column, etc. Please read the [reference](/reference/sql/information-schema/overview.md).

## Data management

* [The Storage Location](/user-guide/concepts/storage-location.md).
* Flush and Compaction for Table & Region.
* Cluster Failover for GreptimeDB by [Setting Remote WAL](./remote-wal/quick-start.md).
* [Flush and Compaction for Table & Region](/reference/sql/functions#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#can-i-set-ttl-or-retention-policy-for-different-tables-or-measurements).
Expand Down

0 comments on commit e03454d

Please sign in to comment.