Lance
Docs /Integrations /Trino /Operations /Procedures /VACUUM

VACUUM

Remove old versions of a Lance table and free the storage they use.

Syntax

ALTER TABLE <table_name> EXECUTE vacuum
ALTER TABLE <table_name> EXECUTE vacuum(retention_threshold => '<duration>')

Parameters

Parameter Description
table_name Fully qualified table name: catalog.schema.table.
retention_threshold Optional. Remove versions older than this duration, for example 7d. Defaults to 14d.

Examples

Remove versions older than 7 days

ALTER TABLE lance.default.users
EXECUTE vacuum(retention_threshold => '7d');

Find versions with the $versions table.

Implementation

The procedure runs on the coordinator and calls Lance's dataset cleanup with a cleanup policy built from the given threshold. Cached dataset metadata for the table is invalidated afterwards.

The latest version and tagged versions are never removed by age alone. Files that no version references are removed only when they are at least 7 days old, to protect in-progress writes.

Limitations

  • Removed versions can no longer be read, so time travel to them stops working
  • Fails if a version to be removed is tagged