≈ The Lake

Part 10 · The Databricks platform · Chapter 37

Managed table features on Databricks

The Databricks-specific layer: predictive optimization, file size autotuning, auto compaction and optimized writes, row-level concurrency, the disk cache and catalog commits, and how each maps to open protocol features.

complete ~20 min

After this chapter you should be able to:
  • Separate what is in the open protocol from what is Databricks runtime behavior.
  • Predict which concurrent writes conflict, with and without row-level concurrency.
  • Choose settings for a high-concurrency write workload.

Most of this book describes things any engine can implement: the protocols, and the open-source code that implements them. This chapter is the exception. It covers what Databricks adds on top of Delta tables, especially Unity Catalog managed tables, and for each feature it separates the part that lives in the open protocol from the part that is a platform service.

The source for the Databricks parts is the Databricks documentation, cited per claim. It describes behavior, not algorithms, so the simulator in src/sim/delta/platform.ts encodes the documented rules: the write-conflict matrices, the file size autotuning formula and the disk cache’s caching rules. Its tests check them against the docs’ own tables.

What is open and what is not

FeatureIn the open formatsDatabricks adds
Predictive optimizationOPTIMIZE, VACUUM and ANALYZE exist in open-source Delta; any engine can run themDeciding when to run them on UC managed tables and running them on serverless compute
Auto compaction, optimized writesBoth exist in open-source Delta (AutoCompact hook, DeltaOptimizedWriterExec), off by defaultOn by default for MERGE, UPDATE and DELETE; background auto compaction; file size autotuning
Row-level concurrencyThe deletionVectors table feature; the open-source conflict checker works at file levelA conflict check that resolves different rows in the same file
Catalog commitsThe catalogManaged table feature in PROTOCOL.mdUnity Catalog as the commit coordinator for managed tables
Disk cacheNothing: it is a property of the cluster, not the tableLocal SSD copy of Parquet data in an intermediate format
Liquid clusteringThe clustering table feature in PROTOCOL.mdAutomatic liquid clustering (choosing keys) through predictive optimization

The pattern is that the protocol defines what a table must contain to be read correctly, such as deletion vectors, the clustering domain metadata and catalog-ratified commits.[PROTOCOL.md: Clustered Table][PROTOCOL.md: Catalog-managed tables] Databricks adds when maintenance runs, how writers resolve conflicts, and where data is cached. A table maintained by Databricks stays readable by any engine that supports its table features.

Quiz Check: open or notAnswers are scheduled for spaced review on the Review page.

Q1. Which of these are defined in Delta's PROTOCOL.md, so any engine can implement them? (Select all.) (select all that apply)

How sure are you?

Predictive optimization

OPTIMIZE, VACUUM and ANALYZE are ordinary commands in open-source Delta (chapter 28). Someone has to decide when to run them: too rarely and small files pile up, too often and compute is wasted rewriting data that was fine.

The protocol side is unchanged: predictive optimization’s OPTIMIZE is an ordinary commit with dataChange = false adds and removes, and its VACUUM deletes files the log no longer references and that are older than the retention period, exactly as in chapter 28.

Quiz Check: predictive optimizationAnswers are scheduled for spaced review on the Review page.

Q1. Predictive optimization runs OPTIMIZE on a table with a Z-order history. What does it do about ZORDER?

How sure are you?

Q2. Which tables does predictive optimization maintain?

How sure are you?

File sizes, auto compaction and optimized writes

Open-source Delta has both write-time fixes from chapter 28, off by default: optimized writes (DeltaOptimizedWriterExec, a shuffle before the write) and auto compaction (the AutoCompact post-commit hook, 128 MB target). Databricks turns them on for the operations that cause small files, and picks file sizes from the table’s size.

The docs’ examples are 307 MB at 3 TB, 512 MB at 5 TB and 716 MB at 7 TB. Those come out exactly if the bounds are read as 2,560 GB and 10,240 GB and the result is rounded down to whole megabytes, which is how autotuneTarget implements it:

// autotuneTarget in src/sim/delta/platform.ts
if (tableBytes <= 2560 * GB) return 256 * MB;
if (tableBytes >= 10240 * GB) return 1024 * MB;
return floorToMB(256 * MB + (tableBytes - 2560 * GB) / (7680 * GB) * (768 * MB));

Larger files mean fewer files to list and open per scan, while a small table keeps enough files for parallelism and for file-level skipping. Chapter 26 shows why file size bounds how much data skipping can prune.

Quiz Check: file sizesAnswers are scheduled for spaced review on the Review page.

Q1. A managed table is 5 TB and has no delta.targetFileSize set. What target file size does Databricks autotune to?

How sure are you?

Q2. On Databricks, can you turn off auto compaction and optimized writes for MERGE, UPDATE and DELETE?

How sure are you?

Row-level concurrency

Chapter 10’s open-source conflict checker works on files. A transaction that read or rewrote a file conflicts with a concurrent commit that removed that file, even if the two changed different rows. On a busy table with small, unpartitioned data, most UPDATEs and MERGEs touch the same few files, so most concurrent pairs conflict.

Deletion vectors (chapter 13) change what an UPDATE or DELETE commits: a new DV for the file instead of a rewritten file. That makes a finer check possible, because the writer knows exactly which row positions it changed in which file.

The open-source checker at the pinned commit has no row-level resolution; its row tracking code handles only backfill commits.[ConflictChecker: row tracking backfill] The protocol gives any writer what it needs to build one, deletion vectors and stable row ids from row tracking, but the resolution itself is writer behavior and outside the spec.

writeConflict in the simulator encodes the matrix above. It resolves “can conflict” by whether the two transactions touch the same files (row-level concurrency off) or the same rows (on).

Quiz Check: concurrencyAnswers are scheduled for spaced review on the Review page.

Q1. Which conditions must hold for row-level concurrency to turn on automatically? (Select all.) (select all that apply)

How sure are you?

Q2. Two concurrent UPDATEs change different rows in the same data file of an unpartitioned table with deletion vectors, on DBR 15.4. What happens?

How sure are you?

Q3. A partitioned table has deletion vectors enabled. Can a concurrent OPTIMIZE (without ZORDER BY) make a DELETE fail?

How sure are you?

Q4. Under Serializable, an INSERT and a concurrent MERGE modify the same rows. Which one fails?

How sure are you?

Disk cache

Object storage reads cost a request and latency per range (chapter 3). Repeated scans of the same files can be served from the worker’s local disk instead. Nothing about this is in a table format: a cache only needs to know when a cached file is no longer valid, and Delta and Iceberg data files are never rewritten in place, so a changed table means new paths.

Quiz Check: disk cacheAnswers are scheduled for spaced review on the Review page.

Q1. How does the disk cache differ from df.cache()?

How sure are you?

Managed tables and catalog commits

Chapter 14 derived catalog-managed tables from the protocol: with the catalogManaged table feature, the catalog ratifies each commit, and writers go through it instead of writing the next log file directly.[PROTOCOL.md: Catalog-managed tables] That is what makes the platform services above safe to run: the catalog sees every commit, so it can schedule maintenance and enforce constraints without racing a writer it cannot see.

Quiz Check: managed tablesAnswers are scheduled for spaced review on the Review page.

Q1. A Delta client writes to a Unity Catalog managed table that uses catalog commits. How is the commit made?

How sure are you?

Choosing settings for a high-concurrency write workload

Take a table that many jobs MERGE into at once, with appends from a stream. Working through the rules above:

  1. Do not partition it, or partition only by something coarse that writers never share. Partitioning turns row-level concurrency off. Use liquid clustering for data skipping instead (chapter 27).
  2. Enable deletion vectors. They make DML commit DVs instead of rewritten files, which keeps OPTIMIZE from conflicting with writers, and they are a requirement for row-level concurrency.
  3. Run DBR 14.3 LTS or above on every writer, so all of them resolve at row level.
  4. Keep WriteSerializable (the default) unless readers need full serializability: under it, appends never conflict with MERGE.
  5. Avoid ZORDER BY on the table; it is the one maintenance operation that still conflicts with DML. Liquid clustering’s OPTIMIZE does not have that restriction in the matrix.
  6. Make the appends blind: no subquery reading the target, or they get MERGE’s concurrency.
  7. Let predictive optimization run maintenance if the table is managed, rather than scheduling OPTIMIZE jobs that compete with writers.

The lab’s first tab lets you check each step: start from a partitioned table without deletion vectors and turn things on one at a time.

Try it

  • Write conflicts. Start with a partitioned table, deletion vectors off: every DML and OPTIMIZE pair conflicts on a shared file. Turn on deletion vectors: the OPTIMIZE cells clear except ZORDER. Untick “partitioned”: row-level concurrency turns on, and DML pairs on different rows commit. Switch to “the same rows”, then to Serializable, and watch INSERT against UPDATE/DELETE/MERGE.
  • File size autotuning. Move the slider through 2.5 TB and 10 TB and compare with the docs’ table.
  • Disk cache. Scan files 0–3, then 2–5: two hits, two misses and two evictions. Overwrite file 2 in place and it is read from object storage again.
Both writers touch the same file and

Row-level concurrency is on.

INSERTDMLOPTIMIZEZORDER
INSERT✓✓✓✓
DML✓✓✓✗
OPTIMIZE✓✓✓✗
ZORDER✓✗✗✗

✓ both commit, ✗ one of them fails, for this overlap. DML is UPDATE, DELETE or MERGE. Hover a cell for the docs' wording. Concurrent metadata changes conflict with everything.

Summary

  • The protocol defines table contents: deletion vectors, row tracking, clustering, catalog-managed commits. Databricks adds scheduling, conflict resolution, caching and defaults on top, and the tables stay readable by other engines.
  • Predictive optimization runs OPTIMIZE (no ZORDER), VACUUM, ANALYZE and REFRESH INDEX on Unity Catalog managed tables using serverless compute, by default.
  • Auto compaction and optimized writes are always on for MERGE, UPDATE and DELETE; file sizes autotune from 256 MB to 1 GB between 2.56 TB and 10 TB.
  • Row-level concurrency (DBR 14.3+, unpartitioned, deletion vectors) lets DML on different rows of the same file commit. Deletion vectors alone keep OPTIMIZE without ZORDER from conflicting with writes.
  • The disk cache is a worker-local copy of Parquet data that fills on read and invalidates on file change. Managed tables bring catalog commits, which give the platform visibility into every commit.

Primary sources

Review this chapter

This chapter has 11 quiz questions.

Review this chapter's cards → Review all due cards