liveBook · Manning

VACUUM TABLE

As explained in Architecting an Apache Iceberg Lakehouse

VACUUM TABLE is a Dremio SQL command that expires old Apache Iceberg snapshots and removes their unreferenced files.

VACUUM TABLE is a Dremio SQL command for expiring Apache Iceberg snapshots and deleting files no longer referenced by the remaining snapshots. It reduces storage usage while preserving the active table state, but removes access to expired historical versions. section 10.3.1

Use retention settings to balance storage, recovery, governance, and workload behavior:

  • Set older_than to expire snapshots before a specific timestamp and retain_last to preserve a baseline number of recent snapshots. section 10.3.1
  • Without parameters, Dremio retains the last snapshot and removes snapshots older than five days. section 10.3.1
  • Keep expiration intervals longer than the maximum expected query duration; expiring a query's starting snapshot can cause the query to fail. section 10.3.1

Expire older snapshots

VACUUM TABLE s3.sales EXPIRE SNAPSHOTS older_than '2024-06-01 00:00:00.000' retain_last 20;

Figure 10.9 When Snapshot 1 expires, only metadata or data files that aren’t associated with the remaining snapshots are deleted.

Shows that expiration deletes only metadata and data files not associated with the snapshots that remain. section 10.3.1

How Architecting an Apache Iceberg Lakehouse covers it

How deep it goes
Explains syntax, defaults, cleanup results, time-travel loss, and long-running-query risks, but not implementation internals.
Examples
Uses a Dremio command that expires snapshots before a timestamp while retaining twenty recent snapshots.
What it assumes
Assumes familiarity with Dremio tables and Apache Iceberg snapshots, while defining the command's cleanup and retention effects.
What you can do after
Operate/configure it with timestamp and snapshot-count retention settings while coordinating schedules with governance and query duration.
How it connects
Connects snapshot expiration with Apache Iceberg, time travel, retention policies, storage usage, and long-running queries.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Architecting an Apache Iceberg Lakehouse. The section links point to the parts of the book it draws on.