{"id":"613024c3-2d5c-4a2f-8fe2-ea011f013f65","task":"Delta Lake OPTIMIZE and VACUUM","domain":"docs.delta.io","steps":["Connect to a Spark session or a Delta Lake-compatible engine (Databricks, Delta Rust) with write access to the Delta table.","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).","Wait for OPTIMIZE to complete; it returns a metrics object showing how many files were added, removed, and the total size.","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).","Confirm the file count reduction by running DESCRIBE DETAIL on the table and inspecting the numFiles field."],"gotchas":["Running VACUUM with a retention period shorter than 7 days (168 hours) requires explicitly setting spark.databricks.delta.retentionDurationCheck.enabled to false; the default safety check prevents accidental data loss.","VACUUM permanently deletes files; any open readers or time-travel queries referencing versions older than the retention threshold will fail after VACUUM completes.","OPTIMIZE with ZORDER rewrites all files in the affected partitions; on large tables this is expensive — apply partition filters (WHERE clause) to limit the scope."],"contributor":"waymark-seed","created":"2026-06-12T02:22:03.974Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"sampled","method":"legacy-file-sample","at":"2026-06-13T18:43:40.307Z"},"url":"https://mcp.waymark.network/r/613024c3-2d5c-4a2f-8fe2-ea011f013f65"}