How Delta keeps query-ready file layout — compaction, data skipping, and the clustering model that replaces partitioning and Z-order without rewriting data.
Delta optimization is the set of layout operations — OPTIMIZE compaction, data skipping via file stats, and liquid clustering — that minimize how much data a query has to read.
Streaming and incremental writes leave tables full of small files; queries then scan far more data than they need. These features pack files to a healthy size, keep per-file statistics so the engine can skip irrelevant files, and physically colocate related rows — so the same query touches a fraction of the table.
Delta auto-collects per-file min/max, null counts and record counts (first 32 columns by default on UC external tables) to skip files that can't match a predicate.
Rewrites many small files into fewer evenly-sized ones; idempotent — a second run on the same data does nothing.
OPTIMIZE … ZORDER BY colocates related data on high-cardinality predicate columns; effectiveness drops with each added column. Only on non-clustered Delta tables.
CLUSTER BY (up to 4 keys) replaces partitioning and Z-order; keys can be redefined with no rewrite of existing data. Recommended for all new tables.
Databricks picks and evolves clustering keys from query history; requires predictive optimization and runs asynchronously.
Auto-runs OPTIMIZE, VACUUM and ANALYZE on UC managed tables on serverless — no manual scheduling.
SQL-- compact small files (idempotent); add ZORDER BY only on non-clustered tables
OPTIMIZE sales;
-- preferred for new tables: liquid clustering, keys editable with no rewrite
CREATE TABLE sales (id INT, region STRING, ts TIMESTAMP)
CLUSTER BY (region, ts);
-- re-cluster only new data incrementally; OPTIMIZE FULL re-clusters everything
OPTIMIZE sales;
Both techniques only pay off when the chosen columns match how queries actually filter the table — and only when those columns have file statistics collected (first 32 columns by default).
CLUSTER BY AUTO to let Databricks choose and evolve keys from query history.ZORDER and CLUSTER BY are mutually exclusive; a clustered table can't also use Z-order or partitioning.OPTIMIZE handles new data; run OPTIMIZE FULL (DBR 16.4+) to recluster everything.StructType/MapType/ArrayType columns; CLUSTER BY AUTO needs predictive optimization.CLUSTER BY keys and can redefine them later with no table rewrite. It's GA from DBR 15.4 LTS and the default recommendation for new tables."OPTIMIZE is idempotent bin-packing — it compacts small files into healthy-sized ones; data skipping then uses per-file min/max stats to skip files that can't match the predicate."OPTIMIZE, VACUUM and ANALYZE automatically on Unity Catalog managed tables on serverless — so you stop hand-scheduling maintenance jobs."Verified against docs.databricks.com · June 2026