Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/reference/sql/create.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ create table if not exists metrics(
with('merge_mode'='last_non_null');
```

Under `last_non_null` mode, the table merges rows with the same primary key and timestamp by keeping the latest value of each field.
Under `last_non_null` mode, the table merges rows with the same primary key and timestamp by keeping the latest non-null value of each field.
```sql
INSERT INTO metrics VALUES ('host1', 0, 0, NULL), ('host2', 1, NULL, 1);
INSERT INTO metrics VALUES ('host1', 0, NULL, 10), ('host2', 1, 11, NULL);
Expand Down
13 changes: 11 additions & 2 deletions docs/user-guide/manage-data/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ That will not update anything:
+-----------+---------------------+------+--------+
```

For more information about the `merge_mode` option, please refer to the [CREATE TABLE](/reference/sql/create.md##create-a-table-with-merge-mode) statement.
For more information about the `merge_mode` option, please refer to the [CREATE TABLE](/reference/sql/create.md#create-a-table-with-merge-mode) statement.

### Avoid updating data by creating table with `append_mode` option

Expand Down Expand Up @@ -294,7 +294,7 @@ You can use Time to Live (TTL) policies to automatically remove stale data from
- Decrease storage costs by cleaning out obsolete data.
- Reduce the number of rows the database has to scan for some queries, potentially increasing query performance.

> Please note that the expired data due to TTL policy may not be deleted right after the expiration time. Instead, they are deleted during the compaction, which is a background job ran asynchronously.
> Please note that the expired data due to TTL policy may not be deleted right after the expiration time. Instead, they are deleted during the compaction, which is a background job run asynchronously.
> If you are testing the TTL policy, be sure to trigger data flush and compaction before querying the data.
> You can use our "[ADMIN](/reference/sql/admin.md)" functions to manually run them.

Expand Down Expand Up @@ -323,6 +323,15 @@ Otherwise, the database TTL policy will be applied to the table.

The value of `'ttl'` can be one of duration (like `1hour 12min 5s`), `instant` or `forever`. See details in [CREATE](/reference/sql/create.md#create-a-table-with-ttl) statement.

Use [`ALTER`](/reference/sql/alter.md#alter-table-options) to modify the TTL of an existing table or database:

```sql
-- for table
ALTER TABLE monitor SET 'ttl'='1 month';
-- for database
ALTER DATABASE test SET 'ttl'='1 month';
```

If you want to remove the TTL policy, you can use the following SQL

```sql
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ create table if not exists metrics(
with('merge_mode'='last_non_null');
```

在 `last_non_null` 模式下,表会通过保留每个字段的最新值来合并具有相同主键和时间戳的行
在 `last_non_null` 模式下,表会通过保留每个字段的最新非 NULL 值来合并具有相同主键和时间戳的行

```sql
INSERT INTO metrics VALUES ('host1', 0, 0, NULL), ('host2', 1, NULL, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ VALUES ("127.0.0.1", "2024-07-11 20:00:01", NULL);
+-----------+---------------------+------+--------+
```

有关 `merge_mode` 选项的更多信息,请参阅 [CREATE TABLE](/reference/sql/create.md##创建带有-merge-模式的表) 语句。
有关 `merge_mode` 选项的更多信息,请参阅 [CREATE TABLE](/reference/sql/create.md#创建带有-merge-模式的表) 语句。

### 通过创建带有 `append_mode` 选项的表来避免更新数据

Expand Down Expand Up @@ -319,7 +319,16 @@ CREATE DATABASE test WITH ('ttl'='7d');
如果 table 有自己的 TTL 策略,则该策略将优先于 database 的 TTL 策略,
否则 database 的 TTL 策略将被应用于 table。

`'ttl'` 参数的值可以是持续时间(例如 `1hour 12min 5s`)、`instant` 或 `forever`。有关详细信息,请参阅 [CREATE](/reference/sql/create.md#create-a-table-with-ttl) 语句的文档。
`'ttl'` 参数的值可以是持续时间(例如 `1hour 12min 5s`)、`instant` 或 `forever`。有关详细信息,请参阅 [CREATE](/reference/sql/create.md#创建指定-ttl-的表) 语句的文档。

使用 [`ALTER`](/reference/sql/alter.md#修改表的参数) 来修改现有表或数据库的 TTL:

```sql
-- 针对表
ALTER TABLE monitor SET 'ttl'='1 month';
-- 针对数据库
ALTER DATABASE test SET 'ttl'='1 month';
```

如果你想移除 TTL 策略,可以使用如下 SQL 语句:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ create table if not exists metrics(
with('merge_mode'='last_non_null');
```

在 `last_non_null` 模式下,表会通过保留每个字段的最新值来合并具有相同主键和时间戳的行
在 `last_non_null` 模式下,表会通过保留每个字段的最新非 NULL 值来合并具有相同主键和时间戳的行

```sql
INSERT INTO metrics VALUES ('host1', 0, 0, NULL), ('host2', 1, NULL, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ VALUES ("127.0.0.1", "2024-07-11 20:00:01", NULL);
+-----------+---------------------+------+--------+
```

有关 `merge_mode` 选项的更多信息,请参阅 [CREATE TABLE](/reference/sql/create.md##创建带有-merge-模式的表) 语句。
有关 `merge_mode` 选项的更多信息,请参阅 [CREATE TABLE](/reference/sql/create.md#创建带有-merge-模式的表) 语句。

### 通过创建带有 `append_mode` 选项的表来避免更新数据

Expand Down Expand Up @@ -291,6 +291,10 @@ Time to Live (TTL) 允许你设置定期删除表中数据的策略,
- 通过清理过期数据来降低存储成本。
- 减少数据库在某些查询中需要扫描的行数,从而提高查询性能。

> 请注意,因 TTL 策略而过期的数据,并不是在 TTL 到期时立刻删除的,而是发生在 compaction 时。compaction 是一个后台任务。
> 如果你在测试 TTL 策略,查询过期数据之前请确保 flush 和 compaction 都已触发过了。
> 你可以使用我们的 ”[ADMIN](/reference/sql/admin.md)“ 函数来手动触发。

你可以在创建每个表时设置 TTL。
例如,以下 SQL 语句创建了一个名为 `monitor` 的表,并设置了 7 天的 TTL 策略:

Expand All @@ -315,7 +319,16 @@ CREATE DATABASE test WITH ('ttl'='7d');
如果 table 有自己的 TTL 策略,则该策略将优先于 database 的 TTL 策略,
否则 database 的 TTL 策略将被应用于 table。

`'ttl'` 参数的值可以是持续时间(例如 `1hour 12min 5s`)、`instant` 或 `forever`。有关详细信息,请参阅 [CREATE](/reference/sql/create.md#create-a-table-with-ttl) 语句的文档。
`'ttl'` 参数的值可以是持续时间(例如 `1hour 12min 5s`)、`instant` 或 `forever`。有关详细信息,请参阅 [CREATE](/reference/sql/create.md#创建指定-ttl-的表) 语句的文档。

使用 [`ALTER`](/reference/sql/alter.md#修改表的参数) 来修改现有表或数据库的 TTL:

```sql
-- 针对表
ALTER TABLE monitor SET 'ttl'='1 month';
-- 针对数据库
ALTER DATABASE test SET 'ttl'='1 month';
```

如果你想移除 TTL 策略,可以使用如下 SQL 语句:

Expand Down
2 changes: 1 addition & 1 deletion versioned_docs/version-0.17/reference/sql/create.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ create table if not exists metrics(
with('merge_mode'='last_non_null');
```

Under `last_non_null` mode, the table merges rows with the same primary key and timestamp by keeping the latest value of each field.
Under `last_non_null` mode, the table merges rows with the same primary key and timestamp by keeping the latest non-null value of each field.
```sql
INSERT INTO metrics VALUES ('host1', 0, 0, NULL), ('host2', 1, NULL, 1);
INSERT INTO metrics VALUES ('host1', 0, NULL, 10), ('host2', 1, 11, NULL);
Expand Down
15 changes: 14 additions & 1 deletion versioned_docs/version-0.17/user-guide/manage-data/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ That will not update anything:
+-----------+---------------------+------+--------+
```

For more information about the `merge_mode` option, please refer to the [CREATE TABLE](/reference/sql/create.md##create-a-table-with-merge-mode) statement.
For more information about the `merge_mode` option, please refer to the [CREATE TABLE](/reference/sql/create.md#create-a-table-with-merge-mode) statement.

### Avoid updating data by creating table with `append_mode` option

Expand Down Expand Up @@ -294,6 +294,10 @@ You can use Time to Live (TTL) policies to automatically remove stale data from
- Decrease storage costs by cleaning out obsolete data.
- Reduce the number of rows the database has to scan for some queries, potentially increasing query performance.

> Please note that the expired data due to TTL policy may not be deleted right after the expiration time. Instead, they are deleted during the compaction, which is a background job run asynchronously.
> If you are testing the TTL policy, be sure to trigger data flush and compaction before querying the data.
> You can use our "[ADMIN](/reference/sql/admin.md)" functions to manually run them.

You can set TTL for every table when creating it. For example, the following SQL statement creates a table named `monitor` with a TTL policy of 7 days:

```sql
Expand All @@ -319,6 +323,15 @@ Otherwise, the database TTL policy will be applied to the table.

The value of `'ttl'` can be one of duration (like `1hour 12min 5s`), `instant` or `forever`. See details in [CREATE](/reference/sql/create.md#create-a-table-with-ttl) statement.

Use [`ALTER`](/reference/sql/alter.md#alter-table-options) to modify the TTL of an existing table or database:

```sql
-- for table
ALTER TABLE monitor SET 'ttl'='1 month';
-- for database
ALTER DATABASE test SET 'ttl'='1 month';
```

If you want to remove the TTL policy, you can use the following SQL

```sql
Expand Down