diff --git a/docs/reference/sql/create.md b/docs/reference/sql/create.md index d6388d004..aa59afea9 100644 --- a/docs/reference/sql/create.md +++ b/docs/reference/sql/create.md @@ -29,7 +29,7 @@ The database can also carry options similar to the `CREATE TABLE` statement by u - `memtable.type` - Type of memtable (`time_series`, `partition_tree`) - `append_mode` - Whether tables in the database should be append-only (`true`/`false`) - `merge_mode` - Strategy for merging duplicate rows (`last_row`, `last_non_null`) -- `skip_wal` - Whether to disable Write-Ahead-Log for tables in the database (`true`/`false`) +- `skip_wal` - Whether to disable Write-Ahead-Log for tables in the database (`'true'`/`'false'`) - `compaction.*` - Compaction-related settings (e.g., `compaction.type`, `compaction.twcs.time_window`) 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 | `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. | | `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. | | `comment` | Table level comment | String value. | -| `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. | +| `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. | | `index.type` | Index type | **Only for metric engine** String value, supports `none`, `skipping`. | #### Create a table with TTL diff --git a/docs/reference/sql/data-types.md b/docs/reference/sql/data-types.md index de66847e6..55e0066ed 100644 --- a/docs/reference/sql/data-types.md +++ b/docs/reference/sql/data-types.md @@ -189,6 +189,44 @@ Supported abbreviations include: | us | microseconds | | ns | nanoseconds | +#### INTERVAL keyword + +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: + +1. In MySQL, the syntax is `INTERVAL {quantity} {unit}`, where `quantity` can be a number or a string depending on the context. For example: +```sql +mysql> SELECT INTERVAL 1 YEAR; ++--------------------------------------------------------------------------------------+ +| IntervalMonthDayNano("IntervalMonthDayNano { months: 12, days: 0, nanoseconds: 0 }") | ++--------------------------------------------------------------------------------------+ +| P1Y0M0DT0H0M0S | ++--------------------------------------------------------------------------------------+ +1 row in set (0.01 sec) + +mysql> SELECT INTERVAL '1 YEAR 2' MONTH; ++--------------------------------------------------------------------------------------+ +| IntervalMonthDayNano("IntervalMonthDayNano { months: 14, days: 0, nanoseconds: 0 }") | ++--------------------------------------------------------------------------------------+ +| P1Y2M0DT0H0M0S | ++--------------------------------------------------------------------------------------+ +1 row in set (0.00 sec) +``` + +2. In PostgreSQL and the default GreptimeDB dialect, it is `INTERVAL '{quantity unit}'`, where the INTERVAL keyword is followed by the interval string: +```sql +public=> SELECT INTERVAL '1 year'; + IntervalMonthDayNano("IntervalMonthDayNano { months: 12, days: 0, nanoseconds: 0 }") +-------------------------------------------------------------------------------------- + 1 year +(1 row) + +public=> SELECT INTERVAL '1 year 2 month'; + IntervalMonthDayNano("IntervalMonthDayNano { months: 14, days: 0, nanoseconds: 0 }") +-------------------------------------------------------------------------------------- + 1 year 2 mons +(1 row) +``` + ## JSON Type (Experimental) :::warning diff --git a/docs/user-guide/deployments-administration/performance-tuning/performance-tuning-tips.md b/docs/user-guide/deployments-administration/performance-tuning/performance-tuning-tips.md index a08d31b71..eaef2f395 100644 --- a/docs/user-guide/deployments-administration/performance-tuning/performance-tuning-tips.md +++ b/docs/user-guide/deployments-administration/performance-tuning/performance-tuning-tips.md @@ -69,6 +69,22 @@ In general, append-only tables have a higher scan performance as the storage eng 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. +### Disable Write-Ahead-Log(WAL) + +If you are consuming and writing to GreptimeDB from replayable data sources such as Kafka, you can further improve write throughput by disabling WAL. + +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. + +Disable WAL by setting the table option `skip_wal='true'`: + +```sql +CREATE TABLE logs( + message STRING, + ts TIMESTAMP TIME INDEX +) WITH (skip_wal = 'true'); +``` + + ## Ingestion ### Metrics diff --git a/docs/user-guide/timezone.md b/docs/user-guide/timezone.md index d04143200..30d1b981e 100644 --- a/docs/user-guide/timezone.md +++ b/docs/user-guide/timezone.md @@ -29,6 +29,10 @@ To configure the time zone for the PostgreSQL client, please refer to the [time 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). +### Dashboard + +The dashboard will use the local timezone as the default timezone value. You can change it in the settings menu. + ### Other clients For other clients, you can change [the default time zone configuration](/user-guide/deployments-administration/configuration.md#default-time-zone-configuration) of GreptimeDB. diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/reference/sql/create.md b/i18n/zh/docusaurus-plugin-content-docs/current/reference/sql/create.md index 94ac3f1e5..4c718a06d 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/reference/sql/create.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/reference/sql/create.md @@ -29,7 +29,7 @@ CREATE DATABASE [IF NOT EXISTS] db_name [WITH ] - `memtable.type` - 内存表类型(`time_series`、`partition_tree`) - `append_mode` - 数据库中的表是否为仅追加模式(`true`/`false`) - `merge_mode` - 合并重复行的策略(`last_row`、`last_non_null`) -- `skip_wal` - 是否为数据库中的表禁用预写日志(`true`/`false`) +- `skip_wal` - 是否为数据库中的表禁用预写日志(`'true'`/`'false'`) - `compaction.*` - 压缩相关设置(如 `compaction.type`、`compaction.twcs.time_window`) 阅读更多关于[表选项](#表选项)的信息。 @@ -155,7 +155,7 @@ GreptimeDB 提供了丰富的索引实现来加速查询,请在[索引](/user- | `merge_mode` | 合并重复行的策略 | 字符串值。只有当 `append_mode` 为 'false' 时可用。默认值为 `last_row`,保留相同主键和时间戳的最后一行。设置为 `last_non_null` 则保留相同主键和时间戳的最后一个非空字段。 | | `comment` | 表级注释 | 字符串值。 | | `index.type` | Index 类型 | **仅用于 metric engine** 字符串值,支持 `none`, `skipping`. | -| `skip_wal` | 是否关闭表的预写日志 | 布尔类型。当设置为 `true` 时表的写入数据将不会持久化到预写日志,可以避免存储磨损同时提升写入吞吐。但是当进程重启时,尚未 flush 的数据会丢失。请仅在数据源本身可以确保可靠性的情况下使用此功能。 | +| `skip_wal` | 是否关闭表的预写日志 | 字符串类型。当设置为 `'true'` 时表的写入数据将不会持久化到预写日志,可以避免存储磨损同时提升写入吞吐。但是当进程重启时,尚未 flush 的数据会丢失。请仅在数据源本身可以确保可靠性的情况下使用此功能。 | #### 创建指定 TTL 的表 例如,创建一个存储数据 TTL(Time-To-Live) 为七天的表: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/reference/sql/data-types.md b/i18n/zh/docusaurus-plugin-content-docs/current/reference/sql/data-types.md index 9c773a449..c53606921 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/reference/sql/data-types.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/reference/sql/data-types.md @@ -189,6 +189,44 @@ SELECT '-1h5m'::INTERVAL; | us | microseconds | | ns | nanoseconds | +#### INTERVAL 关键字 + +在上述示例中,我们使用了 `cast` 类型转换操作 `'{quantity unit}'::INTERVAL` 来演示 interval 类型。实际上,interval 类型也可以使用 `INTERVAL` 关键字支持的语法,不过不同数据库方言之间的行为有所差异: + +1. 在 MySQL 中,语法为 `INTERVAL {quantity} {unit}`,其中 `quantity` 可以是数字或字符串,具体取决于上下文。例如: +```sql +mysql> SELECT INTERVAL 1 YEAR; ++--------------------------------------------------------------------------------------+ +| IntervalMonthDayNano("IntervalMonthDayNano { months: 12, days: 0, nanoseconds: 0 }") | ++--------------------------------------------------------------------------------------+ +| P1Y0M0DT0H0M0S | ++--------------------------------------------------------------------------------------+ +1 row in set (0.01 sec) + +mysql> SELECT INTERVAL '1 YEAR 2' MONTH; ++--------------------------------------------------------------------------------------+ +| IntervalMonthDayNano("IntervalMonthDayNano { months: 14, days: 0, nanoseconds: 0 }") | ++--------------------------------------------------------------------------------------+ +| P1Y2M0DT0H0M0S | ++--------------------------------------------------------------------------------------+ +1 row in set (0.00 sec) +``` + +2. 在 PostgreSQL 和默认的 GreptimeDB 方言中,语法为 `INTERVAL '{quantity unit}'`,即 INTERVAL 关键字后跟 interval 字符串: +```sql +public=> SELECT INTERVAL '1 year'; + IntervalMonthDayNano("IntervalMonthDayNano { months: 12, days: 0, nanoseconds: 0 }") +-------------------------------------------------------------------------------------- + 1 year +(1 row) + +public=> SELECT INTERVAL '1 year 2 month'; + IntervalMonthDayNano("IntervalMonthDayNano { months: 14, days: 0, nanoseconds: 0 }") +-------------------------------------------------------------------------------------- + 1 year 2 mons +(1 row) +``` + ## JSON 类型(实验功能) :::warning diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/deployments-administration/performance-tuning/performance-tuning-tips.md b/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/deployments-administration/performance-tuning/performance-tuning-tips.md index 3aec31cc2..1b97b348b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/deployments-administration/performance-tuning/performance-tuning-tips.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/deployments-administration/performance-tuning/performance-tuning-tips.md @@ -69,6 +69,20 @@ staging_size = "10GB" 如果表不需要去重或性能优先于去重,我们建议为表启用 [append_mode](/reference/sql/create.md#创建-append-only-表)。例如,日志表应该是 append-only 表,因为日志消息可能具有相同的时间戳。 +### 禁用预写式日志(WAL) + +如果您是从 Kafka 等可以重放的数据源消费并写入到 GreptimeDB,可以通过禁用 WAL 来进一步提升写入吞吐量。 + +请注意,当 WAL 被禁用后,未刷新到磁盘或对象存储的数据将无法恢复,需要从原始数据源重新恢复,比如重新从 Kafka 读取或重新抓取日志。 + +通过设置表选项 `skip_wal='true'` 来禁用 WAL: + +```sql +CREATE TABLE logs( + message STRING, + ts TIMESTAMP TIME INDEX +) WITH (skip_wal = 'true'); +``` ## 写入 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/timezone.md b/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/timezone.md index 17ae69abc..76692a9dc 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/timezone.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/timezone.md @@ -29,6 +29,10 @@ GreptimeDB 在数据写入或查询时,会根据指定的时区将时间值从 使用 HTTP API 时,你可以通过 header 参数指定时区。有关更多信息,请参阅 [HTTP API 文档](/user-guide/protocols/http.md#时区)。 +### Dashboard + +Dashboard 将使用本地时区作为默认时区值。您可以在 settings 菜单中更改它。 + ### 其他客户端 对于其他客户端,你可以更改 GreptimeDB 的[默认时区配置](/user-guide/deployments-administration/configuration.md#默认时区配置)。