Understanding Snapshots
Every commit to an Iceberg table creates a snapshot - a complete, immutable view of the table at a point in time:- Reader isolation - Queries see a consistent view
- Time travel - Query historical data
- Rollback - Revert to previous states
- Incremental processing - Track changes between snapshots
Snapshot Retention
By default, all snapshots are retained until explicitly expired. Theexpire_snapshots procedure removes old snapshots:
- All snapshots are treated equally
- Important snapshots can be accidentally expired
- No way to retain specific historical points
Tags: Named Historical Snapshots
Tags are named references to snapshots with their own retention policies:Tag Properties
- Immutable - Tags always point to the same snapshot
- Named - Easy to remember and reference (
Q4-2023vs snapshot ID8372649283746) - Independent retention - Each tag has its own max age
- Lightweight - Just metadata, no data duplication
Tag Retention
Tags control when both the reference and the snapshot can be deleted:expire_snapshots runs:
- Expired tags are removed
- Snapshots referenced only by expired tags can be deleted
- Snapshots referenced by active tags are preserved
Tag Use Cases
Regulatory Compliance
Regulatory Compliance
Retain monthly snapshots for auditing:
Release Milestones
Release Milestones
Mark production releases:
Backup Points
Backup Points
Create recovery points before risky operations:
Hierarchical Retention
Hierarchical Retention
Implement tiered retention (daily/weekly/monthly/yearly):
Branches: Independent Lineages
Branches are mutable named references that can have new snapshots committed to them:Branch vs Tag
Branch Retention
Branches have two retention settings:- Branch retention - How long the branch reference exists
- Snapshot retention - How many snapshots to keep on the branch
expire_snapshots runs:
- Snapshots beyond the retention count are deleted
- After branch expires, all its snapshots can be deleted
Branch Use Cases
Write-Audit-Publish (WAP)
Write-Audit-Publish (WAP)
Validate data before making it visible:
Experimental Features
Experimental Features
Test changes without affecting production:
Staging Environments
Staging Environments
Separate staging from production data:
Parallel Data Processing
Parallel Data Processing
Isolate concurrent data pipelines:
Schema with Branches and Tags
When working with branches:- Writing to a branch uses the table’s current schema
- Querying a branch uses the table’s current schema
- Time travel to a snapshot uses the snapshot’s historical schema
Working with Branches and Tags
Creating
Reading
Writing
Merging
Deleting
Retention Policy Example
Comprehensive retention strategy:Best Practices
Use Branches for Mutable Work
Use Branches for Mutable Work
Branches work well for ongoing development:
- Feature development and testing
- Data quality validation
- Staging environments
- Experimental analyses
Set Appropriate Retention
Set Appropriate Retention
Balance storage cost with recovery needs:
- Short-lived branches (1-7 days) for testing
- Medium-term tags (30-90 days) for regular backups
- Long-term tags (years) for compliance
Name Consistently
Name Consistently
Use clear naming conventions:
daily-YYYY-MM-DDfor daily snapshotsweekly-YYYY-Wwwfor weekly snapshotsmonthly-YYYY-MMfor monthly snapshotsprod-release-vX.Y.Zfor releasesexperiment-descriptionfor tests
Monitor Branch/Tag Count
Monitor Branch/Tag Count
Too many references can slow metadata operations:
- Regularly clean up expired branches
- Automate tag creation/cleanup
- Use
expire_snapshotsregularly
Learn More
Table Format
Understand snapshots and metadata structure
Reliability
Learn about Iceberg’s consistency guarantees