Skip to content

Commit 23f56ed

Browse files
authored
docs: improve data management (#2146)
Signed-off-by: Dennis Zhuang <[email protected]>
1 parent 49574a9 commit 23f56ed

File tree

8 files changed

+55
-11
lines changed

8 files changed

+55
-11
lines changed

docs/reference/sql/create.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ create table if not exists metrics(
261261
with('merge_mode'='last_non_null');
262262
```
263263

264-
Under `last_non_null` mode, the table merges rows with the same primary key and timestamp by keeping the latest value of each field.
264+
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.
265265
```sql
266266
INSERT INTO metrics VALUES ('host1', 0, 0, NULL), ('host2', 1, NULL, 1);
267267
INSERT INTO metrics VALUES ('host1', 0, NULL, 10), ('host2', 1, 11, NULL);

docs/user-guide/manage-data/overview.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ That will not update anything:
177177
+-----------+---------------------+------+--------+
178178
```
179179

180-
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.
180+
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.
181181

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

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

297-
> 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.
297+
> 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.
298298
> If you are testing the TTL policy, be sure to trigger data flush and compaction before querying the data.
299299
> You can use our "[ADMIN](/reference/sql/admin.md)" functions to manually run them.
300300
@@ -323,6 +323,15 @@ Otherwise, the database TTL policy will be applied to the table.
323323

324324
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.
325325

326+
Use [`ALTER`](/reference/sql/alter.md#alter-table-options) to modify the TTL of an existing table or database:
327+
328+
```sql
329+
-- for table
330+
ALTER TABLE monitor SET 'ttl'='1 month';
331+
-- for database
332+
ALTER DATABASE test SET 'ttl'='1 month';
333+
```
334+
326335
If you want to remove the TTL policy, you can use the following SQL
327336

328337
```sql

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ create table if not exists metrics(
265265
with('merge_mode'='last_non_null');
266266
```
267267

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

270270
```sql
271271
INSERT INTO metrics VALUES ('host1', 0, 0, NULL), ('host2', 1, NULL, 1);

i18n/zh/docusaurus-plugin-content-docs/current/user-guide/manage-data/overview.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ VALUES ("127.0.0.1", "2024-07-11 20:00:01", NULL);
174174
+-----------+---------------------+------+--------+
175175
```
176176

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

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

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

322-
`'ttl'` 参数的值可以是持续时间(例如 `1hour 12min 5s`)、`instant``forever`。有关详细信息,请参阅 [CREATE](/reference/sql/create.md#create-a-table-with-ttl) 语句的文档。
322+
`'ttl'` 参数的值可以是持续时间(例如 `1hour 12min 5s`)、`instant``forever`。有关详细信息,请参阅 [CREATE](/reference/sql/create.md#创建指定-ttl-的表) 语句的文档。
323+
324+
使用 [`ALTER`](/reference/sql/alter.md#修改表的参数) 来修改现有表或数据库的 TTL:
325+
326+
```sql
327+
-- 针对表
328+
ALTER TABLE monitor SET 'ttl'='1 month';
329+
-- 针对数据库
330+
ALTER DATABASE test SET 'ttl'='1 month';
331+
```
323332

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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ create table if not exists metrics(
265265
with('merge_mode'='last_non_null');
266266
```
267267

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

270270
```sql
271271
INSERT INTO metrics VALUES ('host1', 0, 0, NULL), ('host2', 1, NULL, 1);

i18n/zh/docusaurus-plugin-content-docs/version-0.17/user-guide/manage-data/overview.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ VALUES ("127.0.0.1", "2024-07-11 20:00:01", NULL);
174174
+-----------+---------------------+------+--------+
175175
```
176176

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

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

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

294+
> 请注意,因 TTL 策略而过期的数据,并不是在 TTL 到期时立刻删除的,而是发生在 compaction 时。compaction 是一个后台任务。
295+
> 如果你在测试 TTL 策略,查询过期数据之前请确保 flush 和 compaction 都已触发过了。
296+
> 你可以使用我们的 ”[ADMIN](/reference/sql/admin.md)“ 函数来手动触发。
297+
294298
你可以在创建每个表时设置 TTL。
295299
例如,以下 SQL 语句创建了一个名为 `monitor` 的表,并设置了 7 天的 TTL 策略:
296300

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

318-
`'ttl'` 参数的值可以是持续时间(例如 `1hour 12min 5s`)、`instant``forever`。有关详细信息,请参阅 [CREATE](/reference/sql/create.md#create-a-table-with-ttl) 语句的文档。
322+
`'ttl'` 参数的值可以是持续时间(例如 `1hour 12min 5s`)、`instant``forever`。有关详细信息,请参阅 [CREATE](/reference/sql/create.md#创建指定-ttl-的表) 语句的文档。
323+
324+
使用 [`ALTER`](/reference/sql/alter.md#修改表的参数) 来修改现有表或数据库的 TTL:
325+
326+
```sql
327+
-- 针对表
328+
ALTER TABLE monitor SET 'ttl'='1 month';
329+
-- 针对数据库
330+
ALTER DATABASE test SET 'ttl'='1 month';
331+
```
319332

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

versioned_docs/version-0.17/reference/sql/create.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ create table if not exists metrics(
261261
with('merge_mode'='last_non_null');
262262
```
263263

264-
Under `last_non_null` mode, the table merges rows with the same primary key and timestamp by keeping the latest value of each field.
264+
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.
265265
```sql
266266
INSERT INTO metrics VALUES ('host1', 0, 0, NULL), ('host2', 1, NULL, 1);
267267
INSERT INTO metrics VALUES ('host1', 0, NULL, 10), ('host2', 1, 11, NULL);

versioned_docs/version-0.17/user-guide/manage-data/overview.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ That will not update anything:
177177
+-----------+---------------------+------+--------+
178178
```
179179

180-
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.
180+
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.
181181

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

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

297+
> 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.
298+
> If you are testing the TTL policy, be sure to trigger data flush and compaction before querying the data.
299+
> You can use our "[ADMIN](/reference/sql/admin.md)" functions to manually run them.
300+
297301
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:
298302

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

320324
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.
321325

326+
Use [`ALTER`](/reference/sql/alter.md#alter-table-options) to modify the TTL of an existing table or database:
327+
328+
```sql
329+
-- for table
330+
ALTER TABLE monitor SET 'ttl'='1 month';
331+
-- for database
332+
ALTER DATABASE test SET 'ttl'='1 month';
333+
```
334+
322335
If you want to remove the TTL policy, you can use the following SQL
323336

324337
```sql

0 commit comments

Comments
 (0)