Maintain DuckLake Storage

On this page

Compact files, expire snapshots, and free storage.

1. Run All Maintenance

ondatrasql checkpoint

Runs all steps in order: flush → expire → merge → rewrite → cleanup → orphaned.

2. Or Run Individual Steps

ondatrasql flush                  # Materialize inlined data to Parquet
ondatrasql expire                 # Remove old snapshot metadata
ondatrasql merge                  # Combine small files
ondatrasql rewrite                # Compact files with many deletes
ondatrasql cleanup                # Delete unused files
ondatrasql orphaned               # Remove stray files from failed writes

3. Schedule Weekly

Use cron to run maintenance weekly:

0 3 * * 0 cd /path/to/project && ondatrasql checkpoint

Note: ondatrasql schedule installs a scheduled ondatrasql run (pipeline execution), not maintenance. Use your system’s cron for checkpoint.

Customizing

Maintenance SQL is editable:

ondatrasql edit checkpoint
ondatrasql edit merge
ondatrasql edit expire

See DuckLake: Recommended Maintenance for details on each operation.