Skip to content

Commit 438e3b1

Browse files
killme2008Copilot
andauthored
docs: dashboard timezone settings and interval keyword (#1992)
Signed-off-by: Dennis Zhuang <[email protected]> Co-authored-by: Copilot <[email protected]>
1 parent 4485371 commit 438e3b1

File tree

8 files changed

+118
-4
lines changed

8 files changed

+118
-4
lines changed

docs/reference/sql/create.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ The database can also carry options similar to the `CREATE TABLE` statement by u
2929
- `memtable.type` - Type of memtable (`time_series`, `partition_tree`)
3030
- `append_mode` - Whether tables in the database should be append-only (`true`/`false`)
3131
- `merge_mode` - Strategy for merging duplicate rows (`last_row`, `last_non_null`)
32-
- `skip_wal` - Whether to disable Write-Ahead-Log for tables in the database (`true`/`false`)
32+
- `skip_wal` - Whether to disable Write-Ahead-Log for tables in the database (`'true'`/`'false'`)
3333
- `compaction.*` - Compaction-related settings (e.g., `compaction.type`, `compaction.twcs.time_window`)
3434

3535
Read more about [table options](#table-options).
@@ -152,7 +152,7 @@ Users can add table options by using `WITH`. The valid options contain the follo
152152
| `append_mode` | Whether the table is append-only | String value. Default is 'false', which removes duplicate rows by primary keys and timestamps according to the `merge_mode`. Setting it to 'true' to enable append mode and create an append-only table which keeps duplicate rows. |
153153
| `merge_mode` | The strategy to merge duplicate rows | String value. Only available when `append_mode` is 'false'. Default is `last_row`, which keeps the last row for the same primary key and timestamp. Setting it to `last_non_null` to keep the last non-null field for the same primary key and timestamp. |
154154
| `comment` | Table level comment | String value. |
155-
| `skip_wal` | Whether to disable Write-Ahead-Log for this table | Boolean type. When set to `true`, the data written to the table will not be persisted to the write-ahead log, which can avoid storage wear and improve write throughput. However, when the process restarts, any unflushed data will be lost. Please use this feature only when the data source itself can ensure reliability. |
155+
| `skip_wal` | Whether to disable Write-Ahead-Log for this table | String type. When set to `'true'`, the data written to the table will not be persisted to the write-ahead log, which can avoid storage wear and improve write throughput. However, when the process restarts, any unflushed data will be lost. Please use this feature only when the data source itself can ensure reliability. |
156156
| `index.type` | Index type | **Only for metric engine** String value, supports `none`, `skipping`. |
157157

158158
#### Create a table with TTL

docs/reference/sql/data-types.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,44 @@ Supported abbreviations include:
189189
| us | microseconds |
190190
| ns | nanoseconds |
191191

192+
#### INTERVAL keyword
193+
194+
In the examples above, we used the cast operation `'{quantity unit}'::INTERVAL` to demonstrate the interval type. In fact, the interval type can also be used with the syntax supported by the `INTERVAL` keyword, though the behavior varies between database dialects:
195+
196+
1. In MySQL, the syntax is `INTERVAL {quantity} {unit}`, where `quantity` can be a number or a string depending on the context. For example:
197+
```sql
198+
mysql> SELECT INTERVAL 1 YEAR;
199+
+--------------------------------------------------------------------------------------+
200+
| IntervalMonthDayNano("IntervalMonthDayNano { months: 12, days: 0, nanoseconds: 0 }") |
201+
+--------------------------------------------------------------------------------------+
202+
| P1Y0M0DT0H0M0S |
203+
+--------------------------------------------------------------------------------------+
204+
1 row in set (0.01 sec)
205+
206+
mysql> SELECT INTERVAL '1 YEAR 2' MONTH;
207+
+--------------------------------------------------------------------------------------+
208+
| IntervalMonthDayNano("IntervalMonthDayNano { months: 14, days: 0, nanoseconds: 0 }") |
209+
+--------------------------------------------------------------------------------------+
210+
| P1Y2M0DT0H0M0S |
211+
+--------------------------------------------------------------------------------------+
212+
1 row in set (0.00 sec)
213+
```
214+
215+
2. In PostgreSQL and the default GreptimeDB dialect, it is `INTERVAL '{quantity unit}'`, where the INTERVAL keyword is followed by the interval string:
216+
```sql
217+
public=> SELECT INTERVAL '1 year';
218+
IntervalMonthDayNano("IntervalMonthDayNano { months: 12, days: 0, nanoseconds: 0 }")
219+
--------------------------------------------------------------------------------------
220+
1 year
221+
(1 row)
222+
223+
public=> SELECT INTERVAL '1 year 2 month';
224+
IntervalMonthDayNano("IntervalMonthDayNano { months: 14, days: 0, nanoseconds: 0 }")
225+
--------------------------------------------------------------------------------------
226+
1 year 2 mons
227+
(1 row)
228+
```
229+
192230
## JSON Type (Experimental)
193231

194232
:::warning

docs/user-guide/deployments-administration/performance-tuning/performance-tuning-tips.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,22 @@ In general, append-only tables have a higher scan performance as the storage eng
6969

7070
We recommend enabling the [append_mode](/reference/sql/create.md#create-an-append-only-table) for the table if it doesn't require deduplication or performance is prioritized over deduplication. For example, a log table should be append-only as log messages may have the same timestamp.
7171

72+
### Disable Write-Ahead-Log(WAL)
73+
74+
If you are consuming and writing to GreptimeDB from replayable data sources such as Kafka, you can further improve write throughput by disabling WAL.
75+
76+
Please note that when WAL is disabled, unflushed data to disk or object storage will not be recoverable and will need to be restored from the original data source, such as re-reading from Kafka or re-fetching logs.
77+
78+
Disable WAL by setting the table option `skip_wal='true'`:
79+
80+
```sql
81+
CREATE TABLE logs(
82+
message STRING,
83+
ts TIMESTAMP TIME INDEX
84+
) WITH (skip_wal = 'true');
85+
```
86+
87+
7288
## Ingestion
7389

7490
### Metrics

docs/user-guide/timezone.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ To configure the time zone for the PostgreSQL client, please refer to the [time
2929

3030
When using the HTTP API, you can specify the time zone through the header parameter. For more information, please refer to the [HTTP API documentation](/user-guide/protocols/http.md#time-zone).
3131

32+
### Dashboard
33+
34+
The dashboard will use the local timezone as the default timezone value. You can change it in the settings menu.
35+
3236
### Other clients
3337

3438
For other clients, you can change [the default time zone configuration](/user-guide/deployments-administration/configuration.md#default-time-zone-configuration) of GreptimeDB.

i18n/zh/docusaurus-plugin-content-docs/current/reference/sql/create.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ CREATE DATABASE [IF NOT EXISTS] db_name [WITH <options>]
2929
- `memtable.type` - 内存表类型(`time_series``partition_tree`
3030
- `append_mode` - 数据库中的表是否为仅追加模式(`true`/`false`
3131
- `merge_mode` - 合并重复行的策略(`last_row``last_non_null`
32-
- `skip_wal` - 是否为数据库中的表禁用预写日志(`true`/`false`
32+
- `skip_wal` - 是否为数据库中的表禁用预写日志(`'true'`/`'false'`
3333
- `compaction.*` - 压缩相关设置(如 `compaction.type``compaction.twcs.time_window`
3434

3535
阅读更多关于[表选项](#表选项)的信息。
@@ -155,7 +155,7 @@ GreptimeDB 提供了丰富的索引实现来加速查询,请在[索引](/user-
155155
| `merge_mode` | 合并重复行的策略 | 字符串值。只有当 `append_mode` 为 'false' 时可用。默认值为 `last_row`,保留相同主键和时间戳的最后一行。设置为 `last_non_null` 则保留相同主键和时间戳的最后一个非空字段。 |
156156
| `comment` | 表级注释 | 字符串值。 |
157157
| `index.type` | Index 类型 | **仅用于 metric engine** 字符串值,支持 `none`, `skipping`. |
158-
| `skip_wal` | 是否关闭表的预写日志 | 布尔类型。当设置为 `true` 时表的写入数据将不会持久化到预写日志,可以避免存储磨损同时提升写入吞吐。但是当进程重启时,尚未 flush 的数据会丢失。请仅在数据源本身可以确保可靠性的情况下使用此功能。 |
158+
| `skip_wal` | 是否关闭表的预写日志 | 字符串类型。当设置为 `'true'` 时表的写入数据将不会持久化到预写日志,可以避免存储磨损同时提升写入吞吐。但是当进程重启时,尚未 flush 的数据会丢失。请仅在数据源本身可以确保可靠性的情况下使用此功能。 |
159159

160160
#### 创建指定 TTL 的表
161161
例如,创建一个存储数据 TTL(Time-To-Live) 为七天的表:

i18n/zh/docusaurus-plugin-content-docs/current/reference/sql/data-types.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,44 @@ SELECT '-1h5m'::INTERVAL;
189189
| us | microseconds |
190190
| ns | nanoseconds |
191191

192+
#### INTERVAL 关键字
193+
194+
在上述示例中,我们使用了 `cast` 类型转换操作 `'{quantity unit}'::INTERVAL` 来演示 interval 类型。实际上,interval 类型也可以使用 `INTERVAL` 关键字支持的语法,不过不同数据库方言之间的行为有所差异:
195+
196+
1. 在 MySQL 中,语法为 `INTERVAL {quantity} {unit}`,其中 `quantity` 可以是数字或字符串,具体取决于上下文。例如:
197+
```sql
198+
mysql> SELECT INTERVAL 1 YEAR;
199+
+--------------------------------------------------------------------------------------+
200+
| IntervalMonthDayNano("IntervalMonthDayNano { months: 12, days: 0, nanoseconds: 0 }") |
201+
+--------------------------------------------------------------------------------------+
202+
| P1Y0M0DT0H0M0S |
203+
+--------------------------------------------------------------------------------------+
204+
1 row in set (0.01 sec)
205+
206+
mysql> SELECT INTERVAL '1 YEAR 2' MONTH;
207+
+--------------------------------------------------------------------------------------+
208+
| IntervalMonthDayNano("IntervalMonthDayNano { months: 14, days: 0, nanoseconds: 0 }") |
209+
+--------------------------------------------------------------------------------------+
210+
| P1Y2M0DT0H0M0S |
211+
+--------------------------------------------------------------------------------------+
212+
1 row in set (0.00 sec)
213+
```
214+
215+
2. 在 PostgreSQL 和默认的 GreptimeDB 方言中,语法为 `INTERVAL '{quantity unit}'`,即 INTERVAL 关键字后跟 interval 字符串:
216+
```sql
217+
public=> SELECT INTERVAL '1 year';
218+
IntervalMonthDayNano("IntervalMonthDayNano { months: 12, days: 0, nanoseconds: 0 }")
219+
--------------------------------------------------------------------------------------
220+
1 year
221+
(1 row)
222+
223+
public=> SELECT INTERVAL '1 year 2 month';
224+
IntervalMonthDayNano("IntervalMonthDayNano { months: 14, days: 0, nanoseconds: 0 }")
225+
--------------------------------------------------------------------------------------
226+
1 year 2 mons
227+
(1 row)
228+
```
229+
192230
## JSON 类型(实验功能)
193231

194232
:::warning

i18n/zh/docusaurus-plugin-content-docs/current/user-guide/deployments-administration/performance-tuning/performance-tuning-tips.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,20 @@ staging_size = "10GB"
6969

7070
如果表不需要去重或性能优先于去重,我们建议为表启用 [append_mode](/reference/sql/create.md#创建-append-only-表)。例如,日志表应该是 append-only 表,因为日志消息可能具有相同的时间戳。
7171

72+
### 禁用预写式日志(WAL)
73+
74+
如果您是从 Kafka 等可以重放的数据源消费并写入到 GreptimeDB,可以通过禁用 WAL 来进一步提升写入吞吐量。
75+
76+
请注意,当 WAL 被禁用后,未刷新到磁盘或对象存储的数据将无法恢复,需要从原始数据源重新恢复,比如重新从 Kafka 读取或重新抓取日志。
77+
78+
通过设置表选项 `skip_wal='true'` 来禁用 WAL:
79+
80+
```sql
81+
CREATE TABLE logs(
82+
message STRING,
83+
ts TIMESTAMP TIME INDEX
84+
) WITH (skip_wal = 'true');
85+
```
7286

7387
## 写入
7488

i18n/zh/docusaurus-plugin-content-docs/current/user-guide/timezone.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ GreptimeDB 在数据写入或查询时,会根据指定的时区将时间值从
2929

3030
使用 HTTP API 时,你可以通过 header 参数指定时区。有关更多信息,请参阅 [HTTP API 文档](/user-guide/protocols/http.md#时区)
3131

32+
### Dashboard
33+
34+
Dashboard 将使用本地时区作为默认时区值。您可以在 settings 菜单中更改它。
35+
3236
### 其他客户端
3337

3438
对于其他客户端,你可以更改 GreptimeDB 的[默认时区配置](/user-guide/deployments-administration/configuration.md#默认时区配置)

0 commit comments

Comments
 (0)