Skip to content

Conversation

@dantengsky
Copy link
Member

@dantengsky dantengsky commented Apr 24, 2025

I hereby agree to the terms of the CLA available at: https://docs.databend.com/dev/policies/cla/

Summary

Introduce new table option data_retention_num_snapshots_to_keep, which allows users to specify the number of snapshots to retain for a table:

create  table t ... data_retention_num_snapshots_to_keep = N;

-- or
alter table t set options(data_retention_num_snapshots_to_keep = N);

this feature is designed to work with the enable_auto_vacuum setting, providing granular control over snapshot retention policies on a per-table basis

Example:



CREATE OR REPLACE TABLE t(c INT);

-- Set the table to retain only the most recent snapshot
ALTER TABLE t SET OPTIONS(data_retention_num_snapshots_to_keep = 1);

-- Enable automatic vacuum to trigger snapshot cleanup
SET enable_auto_vacuum = 1;

-- After each of these operations, only one snapshot will be kept
INSERT INTO t VALUES(1);
INSERT INTO t VALUES(2);
INSERT INTO t VALUES(3);

Tests

  • Unit Test
  • Logic Test
  • Benchmark Test
  • No Test - Explain why

Type of change

  • Bug Fix (non-breaking change which fixes an issue)
  • New Feature (non-breaking change which adds functionality)
  • Breaking Change (fix or feature that could cause existing functionality not to work as expected)
  • Documentation Update
  • Refactoring
  • Performance Improvement
  • Other (please describe):

This change is Reviewable

@github-actions github-actions bot added the pr-refactor this PR changes the code base without new features or bugfix label Apr 24, 2025
@dantengsky dantengsky force-pushed the refacotr-retention-policy branch from dc001b7 to 99c06bd Compare April 25, 2025 12:07
@dantengsky dantengsky marked this pull request as ready for review April 28, 2025 09:03
@dantengsky dantengsky requested review from SkyFan2002 and zhyass April 29, 2025 01:11
Copy link
Member

@SkyFan2002 SkyFan2002 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@BohuTANG BohuTANG merged commit 4cc3cec into databendlabs:main Apr 29, 2025
85 checks passed
@BohuTANG
Copy link
Member

BohuTANG commented Apr 29, 2025

Based on the good PR summary, the doc generated: databendlabs/databend-docs#1972 cc @soyeric128

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-refactor this PR changes the code base without new features or bugfix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants