Skip to content

Commit 6ae80b4

Browse files
Copilotfengjiachun
andauthored
docs: add parallelism parameter for manual compaction (#2203)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: fengjiachun <3860496+fengjiachun@users.noreply.github.com> Co-authored-by: jeremyhi <jiachun_feng@proton.me>
1 parent 7d0eede commit 6ae80b4

File tree

4 files changed

+64
-4
lines changed
  • docs
  • i18n/zh/docusaurus-plugin-content-docs/current

4 files changed

+64
-4
lines changed

docs/reference/sql/admin.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,15 @@ For example:
3232
-- Flush the table test --
3333
admin flush_table("test");
3434

35-
-- Schedule a compaction for table test --
35+
-- Schedule a compaction for table test with default parallelism (1) --
3636
admin compact_table("test");
37+
38+
-- Schedule a regular compaction with parallelism set to 2 --
39+
admin compact_table("test", "regular", "parallelism=2");
40+
41+
-- Schedule an SWCS compaction with default time window and parallelism set to 2 --
42+
admin compact_table("test", "swcs", "parallelism=2");
43+
44+
-- Schedule an SWCS compaction with custom time window and parallelism --
45+
admin compact_table("test", "swcs", "window=1800,parallelism=2");
3746
```

docs/user-guide/deployments-administration/manage-data/compaction.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,11 @@ ADMIN COMPACT_TABLE(
111111
```
112112

113113
The `<strategy_name>` parameter can be either `twcs` or `swcs` (case insensitive) which refer to Time Windowed Compaction Strategy and Strict Window Compaction Strategy respectively.
114-
For the `swcs` strategy, the `<strategy_parameters>` specify the window size (in seconds) for splitting SST files. For example:
114+
For the `swcs` strategy, the `<strategy_parameters>` can specify:
115+
- The window size (in seconds) for splitting SST files
116+
- The `parallelism` parameter to control the level of parallelism for compaction (defaults to 1)
117+
118+
For example, to trigger compaction with a 1-hour window:
115119

116120
```sql
117121
ADMIN COMPACT_TABLE(
@@ -130,6 +134,23 @@ ADMIN COMPACT_TABLE(
130134

131135
When executing this statement, GreptimeDB will split each SST file into segments with a time span of 1 hour (3600 seconds) and merge these segments into a single output, ensuring no overlapping files remain.
132136

137+
You can also specify the `parallelism` parameter to speed up compaction by processing multiple files concurrently:
138+
139+
```sql
140+
-- SWCS compaction with default time window and parallelism set to 2
141+
ADMIN COMPACT_TABLE("monitor", "swcs", "parallelism=2");
142+
143+
-- SWCS compaction with custom time window and parallelism
144+
ADMIN COMPACT_TABLE("monitor", "swcs", "window=1800,parallelism=2");
145+
```
146+
147+
The `parallelism` parameter is also available for regular compaction:
148+
149+
```sql
150+
-- Regular compaction with parallelism set to 2
151+
ADMIN COMPACT_TABLE("monitor", "regular", "parallelism=2");
152+
```
153+
133154
The following diagram shows the process of strict window compression:
134155

135156
In Figure A, there are 3 overlapping SST files: `[0, 3]` (which includes timestamps 0, 1, 2, and 3), `[3, 8]`, and `[8, 10]`.

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,15 @@ GreptimeDB 提供了一些管理函数来管理数据库和数据:
3131
-- 刷新表 test --
3232
admin flush_table("test");
3333

34-
-- 为表 test 启动 compaction 任务 --
34+
-- 为表 test 启动 compaction 任务,默认并行度为 1 --
3535
admin compact_table("test");
36+
37+
-- 启动常规 compaction,并行度设置为 2 --
38+
admin compact_table("test", "regular", "parallelism=2");
39+
40+
-- 启动 SWCS compaction,使用默认时间窗口,并行度设置为 2 --
41+
admin compact_table("test", "swcs", "parallelism=2");
42+
43+
-- 启动 SWCS compaction,自定义时间窗口和并行度 --
44+
admin compact_table("test", "swcs", "window=1800,parallelism=2");
3645
```

i18n/zh/docusaurus-plugin-content-docs/current/user-guide/deployments-administration/manage-data/compaction.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,11 @@ ADMIN COMPACT_TABLE(
108108
```
109109

110110
`<strategy_name>` 参数可以是 `twcs``swcs`(大小写不敏感),分别指定时间窗口压缩策略和严格窗口压缩策略。
111-
对于 `swcs` 策略, `<strategy_parameters>` 指定用于拆分 SST 文件的窗口大小(以秒为单位)。例如:
111+
对于 `swcs` 策略, `<strategy_parameters>` 可以指定:
112+
- 用于拆分 SST 文件的窗口大小(以秒为单位)
113+
- `parallelism` 参数用于控制压缩的并行度(默认为 1)
114+
115+
例如,触发使用 1 小时窗口的压缩:
112116

113117
```sql
114118
ADMIN COMPACT_TABLE(
@@ -127,6 +131,23 @@ ADMIN COMPACT_TABLE(
127131

128132
执行此语句时,GreptimeDB 会将每个 SST 文件按 1 小时(3600 秒)的时间跨度拆分成多个分块,并将这些分块合并为一个输出文件,确保没有重叠的文件。
129133

134+
你还可以指定 `parallelism` 参数来通过并发处理多个文件以加速压缩:
135+
136+
```sql
137+
-- 使用默认时间窗口和并行度为 2 的 SWCS 压缩
138+
ADMIN COMPACT_TABLE("monitor", "swcs", "parallelism=2");
139+
140+
-- 使用自定义时间窗口和并行度的 SWCS 压缩
141+
ADMIN COMPACT_TABLE("monitor", "swcs", "window=1800,parallelism=2");
142+
```
143+
144+
`parallelism` 参数同样适用于常规压缩:
145+
146+
```sql
147+
-- 并行度为 2 的常规压缩
148+
ADMIN COMPACT_TABLE("monitor", "regular", "parallelism=2");
149+
```
150+
130151
下图展示了一次 SWCS 压缩的过程:
131152

132153
在图 A 中,有 3 个重叠的 SST 文件,分别是 `[0, 3]`(也就是包含 0、1、2、3 的时间戳)、`[3, 8]``[8, 10]`

0 commit comments

Comments
 (0)