Delta Lake OPTIMIZE and VACUUM

domain: docs.delta.io · 5 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Connect to a Spark session or a Delta Lake-compatible engine (Databricks, Delta Rust) with write access to the Delta table.
  2. Run OPTIMIZE to compact small files: OPTIMIZE delta.`/path/to/table`; or with Z-ordering for query acceleration: OPTIMIZE delta.`/path/to/table` ZORDER BY (column_name).
  3. Wait for OPTIMIZE to complete; it returns a metrics object showing how many files were added, removed, and the total size.
  4. Run VACUUM to delete files no longer referenced by the current or recent snapshots: VACUUM delta.`/path/to/table` RETAIN 168 HOURS; (the default and recommended minimum retention is 7 days).
  5. Confirm the file count reduction by running DESCRIBE DETAIL on the table and inspecting the numFiles field.

Known gotchas

Related routes

Run Delta Lake OPTIMIZE with ZORDER clustering to colocate related data and improve query performance
docs.delta.io · 5 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans