Skip to main content
Enterprise only
VACUUM submits a durable cleanup job for a table. The statement returns a job_id after submission; cleanup continues in the background.
The corresponding Enterprise CLI command is:
Configure the CLI’s database and Flight SQL endpoint before running it. Waiting also needs the REST endpoint. It uses the same waiter as PREWARM and OPTIMIZE: timeout stops waiting and leaves the job running; failed or cancelled jobs produce a nonzero exit. Save the returned job ID to inspect it later.

Progress, result and preview

Describe reports cleanup phases such as preparing, deleting_versions, pruning_sidecars, trimming_fragment_reuse_index, retrying and auxiliary_sweeps. These are execution observations, not a completion percentage. A successful current worker publishes a versioned result:
Counts cover version deletion only. After retry or recovery, earlier deletion may be unobserved: statistics_complete is false and both counts are null. Zero means measured zero work. failed_deletes reports failed object deletions when measured; successful removals remain committed even if some deletions failed. Older workers can omit measurements or the entire result. Auxiliary scratch, staged-target, resource-history and retired write-ahead-log sweeps remain best effort and are excluded from these counts. Failure or cancellation can follow partial deletion and cannot undo it. Preview version/file deletion without submitting a job or changing table state:
Plain/TEXT and JSON return plan_type=logical_plan and a JSON plan with format_version=1, source_version, min_age_seconds, cutoff_millis, versions_to_remove and bytes_to_remove. Preview uses the pinned Lance library’s read-only explanation and the same retention/reference rules as the worker. Counts exclude auxiliary sweeps; file paths are not exposed. It can perform metadata/object-store listing. EXPLAIN ANALYZE is rejected. A preview reserves no files or snapshot. Execution opens latest branch state, re-evaluates references and calculates its cutoff then, so actual removals may differ. Preview does not require stopping automatic work because it does not delete; the coordination below is required before actual submission.

Coordinate before running

Manual cleanup reuses the existing cleanup worker. This release requires operator coordination and does not provide storage-level exclusion against concurrent tag creation/update, branch creation or restore. A successful concurrent reference operation can otherwise point to deleted history; a concurrent restore can leave the current table unreadable. Before submission, disable automatic cleanup for the table and its branches with job_types.cleanup.enabled = false and wait for existing cleanup workers to finish. Prevent other manual cleanup and history-reference mutations on the table, including through direct storage clients, until the submitted worker finishes. Restore the previous automatic cleanup setting afterward. Disabling scheduling does not stop running work, and cancelling a job does not establish that already-issued storage requests have stopped. Submission does not disable scheduling, drain workers or block these operations for you. This coordination is required for every retention value, including zero. Listing existing jobs with lancedb job list requires system Usage; a table owner without that permission needs an operator with job-list access to coordinate the drain.

Retention

Each run resolves its minimum version age in this order:
  1. Invocation min_age_seconds / CLI --min-age-seconds.
  2. The selected table/branch’s job_types.cleanup.ttl_seconds.
  3. Deployment default.
For operator configuration, see the deployment configuration guidance.
If no retention value resolves, supply an explicit min_age_seconds. Negative, fractional and out-of-range values are rejected. Zero allows all old versions to be considered. With the coordination above, the worker honors existing current, tag and branch references and retains its safeguards for recent unverified files. Shortening retention can permanently remove historical versions; increasing it later cannot restore them. Cleanup does not guarantee immediate reclamation of every orphaned file. The resolved age is recorded in the job. Changing table policy afterward does not change that run. Invocation options never modify persistent table policy.

Automatic cleanup and job identity

Manual cleanup can run while automatic cleanup is disabled. Automatic cleanup keeps its existing enablement, cadence, retry and stale-retention checks. A fresh invocation creates a distinct job, even if an automatic cleanup job already exists. Every SQL execution generates a fresh request identity, so retrying the statement can submit another job. Existing execution safeguards apply; one worker per job does not provide a table-wide lock across jobs.

Authorization and status

Submission requires table Ownership and database/namespace Usage. A missing table or branch fails before job creation. With REST connectivity configured:
job describe accepts system Usage or Usage on the job’s database and every namespace in its path. Configure the same database when using the scoped permission. job events requires system Usage. System Operate is not required to describe a cleanup job.

Admin REST API

POST /admin/table/cleanup accepts the logical target and optional retention:
Use branch to select another branch. A successful response is HTTP 202 with {"job_id":"..."}. The same active request key reuses its job; deduplication is not retained after completion. This endpoint and SQL require a server release with manual cleanup support. SDK cleanup_async / cleanupAsync support is delivered separately and requires the matching result contract. The REST route is an explicit administrative adapter for operators and REST integrations. SQL is the canonical CLI/SDK submission path. Both adapters use the same cleanup service; the CLI does not fall back to REST on SQL errors. Manual submission requires the durable Job Registry and the current Rust agent/worker execution path.