Skip to content

Commit 3d53d83

Browse files
authored
fuse: add enable_auto_vacuum and data_retention_num_snapshots_to_keep (#2003)
1 parent 2c36dfc commit 3d53d83

File tree

1 file changed

+63
-2
lines changed
  • docs/en/sql-reference/00-sql-reference/30-table-engines

1 file changed

+63
-2
lines changed

docs/en/sql-reference/00-sql-reference/30-table-engines/00-fuse.md

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: Fuse Engine Tables
44

55
import FunctionDescription from '@site/src/components/FunctionDescription';
66

7-
<FunctionDescription description="Introduced or updated: v1.2.733"/>
7+
<FunctionDescription description="Introduced or updated: v1.2.73666666"/>
88

99
## Overview
1010

@@ -133,10 +133,71 @@ Below are the available Fuse Engine options, grouped by their purpose:
133133

134134
---
135135

136+
### `enable_auto_vacuum`
137+
- **Syntax:**
138+
`enable_auto_vacuum = 0 / 1`
139+
- **Description:**
140+
Controls whether a table automatically triggers vacuum operations during mutations. This can be set globally as a setting for all tables or configured at the table level. The table-level option has a higher priority than the session/global setting of the same name. When enabled (set to 1), vacuum operations will be automatically triggered after mutations like INSERT or ALTER TABLE, cleaning up the table data according to the configured retention policy.
141+
142+
**Examples:**
143+
```sql
144+
-- Set enable_auto_vacuum globally for all tables across all sessions
145+
SET GLOBAL enable_auto_vacuum = 1;
146+
147+
-- Create a table with auto vacuum disabled (overrides global setting)
148+
CREATE OR REPLACE TABLE t1 (id INT) ENABLE_AUTO_VACUUM = 0;
149+
INSERT INTO t1 VALUES(1); -- Won't trigger vacuum despite global setting
150+
151+
-- Create another table that inherits the global setting
152+
CREATE OR REPLACE TABLE t2 (id INT);
153+
INSERT INTO t2 VALUES(1); -- Will trigger vacuum due to global setting
154+
155+
-- Enable auto vacuum for an existing table
156+
ALTER TABLE t1 SET OPTIONS(ENABLE_AUTO_VACUUM = 1);
157+
INSERT INTO t1 VALUES(2); -- Now will trigger vacuum
158+
159+
-- Table option takes precedence over global settings
160+
SET GLOBAL enable_auto_vacuum = 0; -- Turn off globally
161+
-- t1 will still vacuum because table setting overrides global
162+
INSERT INTO t1 VALUES(3); -- Will still trigger vacuum
163+
INSERT INTO t2 VALUES(2); -- Won't trigger vacuum anymore
164+
```
165+
166+
---
167+
136168
### `data_retention_num_snapshots_to_keep`
137169
- **Syntax:**
138170
`data_retention_num_snapshots_to_keep = <n>`
139171
- **Description:**
140-
Specifies the number of snapshots to retain for a table. This option works in conjunction with the `enable_auto_vacuum` setting to provide granular control over snapshot retention policies on a per-table basis. When set, only the specified number of most recent snapshots will be kept after vacuum operations.
172+
Specifies the number of snapshots to retain during vacuum operations. This can be set globally as a setting for all tables or configured at the table level. The table-level option has a higher priority than the session/global setting of the same name. When set, only the specified number of most recent snapshots will be kept after vacuum operations. Overrides the `data_retention_time_in_days` setting. If set to 0, this setting will be ignored. This option works in conjunction with the `enable_auto_vacuum` setting to provide granular control over snapshot retention policies.
173+
174+
**Examples:**
175+
```sql
176+
-- Set global retention to 10 snapshots for all tables across all sessions
177+
SET GLOBAL data_retention_num_snapshots_to_keep = 10;
178+
179+
-- Create a table with custom snapshot retention (overrides global setting)
180+
CREATE OR REPLACE TABLE t1 (id INT)
181+
enable_auto_vacuum = 1
182+
data_retention_num_snapshots_to_keep = 5;
183+
184+
-- Create another table that inherits the global setting
185+
CREATE OR REPLACE TABLE t2 (id INT) enable_auto_vacuum = 1;
186+
187+
-- When vacuum is triggered:
188+
-- t1 will keep 5 snapshots (table setting)
189+
-- t2 will keep 10 snapshots (global setting)
190+
191+
-- Change global setting
192+
SET GLOBAL data_retention_num_snapshots_to_keep = 20;
193+
194+
-- Table options still take precedence:
195+
-- t1 will still keep only 5 snapshots
196+
-- t2 will now keep 20 snapshots
197+
198+
-- Modify snapshot retention for an existing table
199+
ALTER TABLE t1 SET OPTIONS(data_retention_num_snapshots_to_keep = 3);
200+
-- Now t1 will keep 3 snapshots when vacuum is triggered
201+
```
141202

142203
---

0 commit comments

Comments
 (0)