Skip to content

Commit b0ff913

Browse files
authored
doc: add data_retention_num_snapshots_to_keep (#1972)
1 parent 0c2668f commit b0ff913

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

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

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

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

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

99
Databend utilizes the Fuse Engine as its default engine, offering a data management system with a user-friendly interface reminiscent of Git. Users have the ability to effortlessly query data at any given moment and effortlessly restore data to any desired point in time.
1010

@@ -41,3 +41,4 @@ The following are the available Fuse Engine options:
4141
| row_per_block | `row_per_block = <n>` | Specifies the maximum number of rows in a file. Defaults to 1,000,000. |
4242
| change_tracking | `change_tracking = True / False` | Setting this option to `True` in the Fuse Engine allows for tracking changes for a table.<br/>Creating a stream for a table will automatically set `change_tracking` to `True` and introduce additional hidden columns to the table as change tracking metadata. For more information, see [How Stream Works](/guides/load-data/continuous-data-pipelines/stream#how-stream-works). |
4343
| data_retention_period_in_hours | `data_retention_period_in_hours = <n>` | Specifies the number of hours to retain table data. The minimum value is 1 hour. The maximum value is defined by the `data_retention_time_in_days_max` setting in the [databend-query.toml](https://github.com/databendlabs/databend/blob/main/scripts/distribution/configs/databend-query.toml) configuration file , or defaults to 2,160 hours (90 days x 24 hours) if not specified. |
44+
| data_retention_num_snapshots_to_keep | `data_retention_num_snapshots_to_keep = <n>` | 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. |

docs/en/sql-reference/10-sql-commands/00-ddl/01-table/90-alter-table-option.md

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ sidebar_position: 5
44
---
55
import FunctionDescription from '@site/src/components/FunctionDescription';
66

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

99
Sets or unsets [Fuse Engine options](../../../00-sql-reference/30-table-engines/00-fuse.md#fuse-engine-options) for a table.
1010

@@ -23,12 +23,15 @@ Please note that only the following Fuse Engine options can be unset:
2323
- `block_per_segment`
2424
- `block_size_threshold`
2525
- `data_retention_period_in_hours`
26+
- `data_retention_num_snapshots_to_keep`
2627
- `row_avg_depth_threshold`
2728
- `row_per_block`
2829
- `row_per_page`
2930

3031
## Examples
3132

33+
### Setting Fuse Engine Options
34+
3235
The following demonstrates how to set Fuse Engine options and verify changes with [SHOW CREATE TABLE](show-create-table.md):
3336

3437
```sql
@@ -59,6 +62,26 @@ Create Table: CREATE TABLE fuse_table (
5962
) ENGINE=FUSE BLOCK_PER_SEGMENT='500' COMPRESSION='lz4' DATA_RETENTION_PERIOD_IN_HOURS='240' STORAGE_FORMAT='native'
6063
```
6164

65+
The following demonstrates how to use the `data_retention_num_snapshots_to_keep` option with `enable_auto_vacuum`:
66+
67+
```sql
68+
-- Create a new table
69+
CREATE OR REPLACE TABLE t(c INT);
70+
71+
-- Set the table to retain only the most recent snapshot
72+
ALTER TABLE t SET OPTIONS(data_retention_num_snapshots_to_keep = 1);
73+
74+
-- Enable automatic vacuum to trigger snapshot cleanup
75+
SET enable_auto_vacuum = 1;
76+
77+
-- After each of these operations, only one snapshot will be kept
78+
INSERT INTO t VALUES(1);
79+
INSERT INTO t VALUES(2);
80+
INSERT INTO t VALUES(3);
81+
```
82+
83+
### Unsetting Fuse Engine Options
84+
6285
The following demonstrates how to unset Fuse Engine options, reverting them to their default values:
6386

6487
```sql
@@ -70,5 +93,4 @@ SHOW CREATE TABLE fuse_table;
7093
Table: fuse_table
7194
Create Table: CREATE TABLE fuse_table (
7295
a INT NULL
73-
) ENGINE=FUSE COMPRESSION='lz4' STORAGE_FORMAT='native'
74-
```
96+
) ENGINE=FUSE COMPRESSION='lz4' STORAGE_FORMAT='native'

0 commit comments

Comments
 (0)