← Delta Optimization track

Databricks · Delta Optimization · Lesson 11

Predictive
Optimization.

Let the platform run your table maintenance. On Unity Catalog managed tables, Databricks automatically runs OPTIMIZE, VACUUM, and ANALYZE on serverless — so you stop scheduling maintenance jobs entirely.

UC managed only Default-on accts ≥ Nov 11 2024 Runs on serverless Verified Jun 2026 docs

What it is

Analogy Use case

Predictive optimization (PO) is Databricks running your table maintenance for you, automatically, on Unity Catalog managed tables (Delta and Iceberg). It watches how each table is written and queried, then runs the three commands you'd otherwise schedule by hand:

It also collects stats on write and eliminates manual maintenance on managed tables. PO runs on serverless compute in the background, so it never competes with your clusters.

Analogy. It's a self-cleaning oven: you cook (write + query); the oven decides when it's dirty enough and runs a cleaning cycle quietly on its own. You never schedule "clean the oven Tuesdays at 2am" again.

Use case. A platform team owns 4,000 UC managed tables. Hand-scheduling OPTIMIZE/VACUUM/ANALYZE per table is unmaintainable. Enable PO once at the catalog level; every table inherits it and Databricks runs the right maintenance on each — no jobs, no schedules.

The closing message of this track For new work, stop hand-tuning layout and maintenance. Use a UC managed table + liquid clustering + predictive optimization, and let the platform do it.

Why it matters

The one rule to remember PO's OPTIMIZE does not run ZORDER (it ignores Z-ordered files). For colocation-for-skipping under PO, use liquid clustering — and raise delta.deletedFileRetentionDuration before enabling PO if you need long time travel.

See it work — enablement inheritance

Enablement flows down a hierarchy: account → catalog → schema → table. Lower levels INHERIT by default; a table's effective state is the nearest explicit ENABLE/DISABLE above it. Click a level to set its state and watch the effective state on the table change. Note the trap: a child DISABLE wins over a parent ENABLE.

Enablement inheritance tree

Set each level to ENABLE / DISABLE / INHERIT. The dashed node is a UC managed table; its effective state is computed by walking up.

Account accounts consoleSettings → Feature enablement —
Catalog analyticsALTER CATALOG … —
Schema analytics.prodALTER SCHEMA … —
Table analytics.prod.eventsUC MANAGED · inherits unless set —
—
effective on table
—
decided at level

Simplified illustration of the inheritance model. "Effective" = the nearest explicit ENABLE/DISABLE walking up from the table; the account has no INHERIT (it's the root). Verify real state with DESCRIBE … EXTENDED.

See it work — the maintenance queue

Once enabled, PO scans your managed tables, queues the ones that would benefit, and runs the right operation on serverless. Step through a cycle and watch which table gets which op — and which gets skipped because it's already healthy.

Predictive optimization — maintenance queue

Five UC managed tables. PO scans each, then queues OPTIMIZE / VACUUM / ANALYZE only where it helps.

0
tables scanned
0
maintenance ops queued
0
already healthy (skipped)
Click Step ▶ to scan the first table.
queued op skipped (healthy)

Simplified illustration. Real PO uses internal heuristics over write/query signals to decide which tables to maintain and when; it runs asynchronously on serverless.

How it works — sub-topic by sub-topic

01What PO runs: OPTIMIZE, VACUUM, ANALYZE (+ stats on write)

On UC managed tables (Delta + Iceberg), PO automatically runs OPTIMIZE (compaction; clustering for LC tables), VACUUM (remove unreferenced files), and ANALYZE (refresh skipping stats), and collects stats on write. These three commands are the entire manual-maintenance burden — automating them means no jobs to author. PO is the operational layer; you still pick the layout (liquid clustering vs. legacy partitioning/Z-order) and PO keeps it healthy.

SQL-- There is no "run PO" command — it runs automatically once enabled.
-- These are the ops PO performs FOR you on a managed table; you stop scheduling them:
--   OPTIMIZE  analytics.prod.events;                        -- compaction (+ clustering for LC)
--   VACUUM    analytics.prod.events;                        -- reclaim files past retention
--   ANALYZE   analytics.prod.events COMPUTE DELTA STATISTICS; -- refresh skipping stats
-- After enabling PO, DELETE the hand-scheduled jobs that ran the above.

02Prerequisites

If any prerequisite is missing (external table, hive_metastore, non-Premium, unsupported region), PO simply won't run there — you're back to manual maintenance for those tables.

03The enablement inheritance model

Set a state at the account, catalog, or schema level; lower levels inherit by default, and a table's effective state is the nearest explicit ENABLE/DISABLE above it. States: ENABLE (on here + below), DISABLE (off here + below), INHERIT (defer to parent). A child DISABLE wins over a parent ENABLE — set the level back to INHERIT/ENABLE to re-cover it.

SQL-- CATALOG level: turn PO on for the whole catalog; schemas/tables inherit unless overridden.
ALTER CATALOG analytics ENABLE PREDICTIVE OPTIMIZATION;

-- SCHEMA / DATABASE level: explicitly OFF for one schema (this wins over the catalog ENABLE).
ALTER SCHEMA analytics.staging DISABLE PREDICTIVE OPTIMIZATION;

-- Go back to inheriting the parent's decision (removes the explicit override).
ALTER SCHEMA analytics.staging INHERIT PREDICTIVE OPTIMIZATION;

04Account-level enablement is UI-driven

The account-level toggle lives in the accounts console, not in SQL. Catalog/schema overrides are then done in SQL (above).

Step-by-step UI actions (account-level):

Verify the exact labels against the current docs — accounts-console wording drifts.

05Privileges

PO enablement is a governance decision tied to UC ownership — if you're not the owner, request the owner (or an account admin) to set it.

06PO's OPTIMIZE does NOT run ZORDER — use liquid clustering

The OPTIMIZE PO runs does compaction (and clustering for LC tables) but does not run ZORDER — it ignores Z-ordered files. For colocation-for-skipping under PO, use liquid clustering; PO even drives automatic key selection for CLUSTER BY AUTO. If you rely on ZORDER and expect PO to maintain it — it won't.

SQL-- WRONG expectation: PO will NOT maintain this Z-order layout (it ignores Z-ordered files).
-- OPTIMIZE legacy_tbl ZORDER BY (customer_id);   -- manual-only; PO does not run ZORDER

-- RIGHT for PO: use liquid clustering so PO's OPTIMIZE colocates data by the keys.
CREATE OR REPLACE TABLE analytics.prod.events (
  event_id   BIGINT,
  event_type STRING,
  event_date DATE
)
CLUSTER BY (event_type, event_date);   -- PO maintains this; CLUSTER BY AUTO lets PO pick keys

07VACUUM retention: delta.deletedFileRetentionDuration (default 7 days)

PO's VACUUM deletes unreferenced files older than the retention window set by delta.deletedFileRetentionDuration (default 7 days). Time travel can only reach as far back as files still exist, so the window bounds how far back you can travel. If you need longer time travel, raise the property BEFORE enabling PO — otherwise PO can delete files you expected to reach.

SQL-- Need 30 days of time travel? RAISE retention BEFORE enabling PO,
-- or PO's VACUUM (default 7 days) reclaims files you wanted to keep.
ALTER TABLE analytics.prod.events
  SET TBLPROPERTIES ('delta.deletedFileRetentionDuration' = '30 days');

-- THEN enable PO (e.g. at schema or catalog level) so it respects the new window.
ALTER SCHEMA analytics.prod ENABLE PREDICTIVE OPTIMIZATION;

08Runs on serverless compute (serverless jobs SKU)

PO executes on serverless compute, billed under the serverless jobs SKU, asynchronously in the background — it never runs on, or competes with, your interactive/job clusters. It's not free, but it's typically cheaper and more correct than over-running hand-scheduled jobs. Monitor cost via the system table (below).

09Monitor with the system table

Every PO operation is logged to system.storage.predictive_optimization_operations_history — query which tables PO touched, which op ran, and the metrics/cost.

SQL-- What has PO done lately, and what did it cost? Audit + cost attribution.
SELECT operation_type, catalog_name, schema_name, table_name,
       operation_status, start_time
FROM system.storage.predictive_optimization_operations_history
WHERE start_time >= current_timestamp() - INTERVAL 7 DAYS
ORDER BY start_time DESC;

10Verify the effective state with DESCRIBE … EXTENDED

Use DESCRIBE (CATALOG | SCHEMA | TABLE) EXTENDED name to read the "Predictive Optimization" field and see the effective state (including whether it's inherited). Because of inheritance + overrides, the effective state isn't always obvious — this is the source of truth per object.

SQL-- Confirm PO is in effect (and whether it's inherited) at each level:
DESCRIBE CATALOG EXTENDED analytics;                 -- catalog-level state
DESCRIBE SCHEMA  EXTENDED analytics.prod;            -- schema-level state
DESCRIBE TABLE   EXTENDED analytics.prod.events;     -- table "Predictive Optimization" field

11What PO does NOT run on

PO needs ownership/lifecycle control over the table's files. For external/legacy tables you still schedule maintenance manually, or migrate them to UC managed tables to get PO.

PO vs. hand-scheduled maintenance

DimensionPredictive optimization (managed)Hand-scheduled OPTIMIZE/VACUUM/ANALYZE
Who runs itDatabricks, automaticallyYou, via jobs/schedules
What it runsOPTIMIZE, VACUUM, ANALYZE (+ stats on write)Whatever you script
Table scopeUC managed only (Delta + Iceberg)Any table (managed/external/hive_metastore)
Z-orderNot run (ignores Z-ordered files) — use liquid clusteringYou can run ZORDER manually
ComputeServerless (serverless jobs SKU), asyncYour clusters/warehouses
TuningPlatform decides which tables + whenYou guess frequency per table
EnablementInherited account → catalog → schema → tablen/a (you author each job)
Time travelBound by deletedFileRetentionDuration (default 7d)Same property, but you control VACUUM timing
Verdict for new code✔ Prefer on UC managed tablesLegacy/external tables, or special timing needs

Uses, edge cases & limitations

Uses (when to reach for it)

Edge cases an interviewer probes

Limitations

Common gotchas

Whole-track recap — the decision ladder

This is the final lesson, so here is the entire track as one decision ladder. Each rung solves a problem the previous rung exposed.

1Traditional write (L01) — the baseline and the small-file problem: Spark writes ~1 file per task.
2Partitioning (L02) — the old physical layout; only for large (>1 TB), low-cardinality tables. Over-partitioning makes small files worse.
3Data skipping & Z-ordering (L03) — why layout matters: per-file min/max stats let the engine skip files; Z-order colocates rows.
4OPTIMIZE / compaction (L04) — the manual fix for small files (bin-packing), idempotent, optionally WHERE/FULL.
5Optimized writes + auto compaction (L05–06) — automatic file sizing at and just-after write (always on for MERGE/UPDATE/DELETE).
6Auto optimize (L07) — the umbrella over the two, plus target-file-size autotuning by table size.
7Liquid clustering (L08) — the modern layout: CLUSTER BY replaces partitioning and Z-order; change keys with no rewrite.
8Deletion vectors (L09) — merge-on-read modifications: DELETE/UPDATE/MERGE mark rows deleted instead of rewriting whole Parquet files.
9VACUUM, time travel & retention (L10) — manage the file history operations leave behind: time-travel to old versions, then VACUUM to reclaim storage.
10Predictive optimization (L11 — this one) — fully managed maintenance: the platform runs OPTIMIZE/VACUUM/ANALYZE on UC managed tables so you don't.
The one-line modern default UC managed table + liquid clustering + predictive optimization. Pick a governed managed table, lay it out with liquid clustering (or CLUSTER BY AUTO), enable predictive optimization — and let the platform do it. Reach for partitioning, Z-order, or hand-scheduled maintenance only for legacy/external tables or special cases.