Disk cache, change data feed, and query profile
Databricks Data Engineer Professional · Lesson 15 of 21 · 1:56:28
YouTube loads only after you press play. This chapter opens at its timestamp in the full course. Watch on YouTube ↗
Learning with these videos? Subscribe for new courses and exam-style questions.
Subscribe on YouTube (opens in a new tab)In this lesson
Prepare for the Databricks Certified Data Engineer Professional exam. In this lesson: reading less data: the disk cache, the change data feed, and the query profile. Includes three original practice questions.
Study notes
The text of this lesson, to read at your own pace. Information as of November 2026.
Reading too much
At Quayside Eats, several notebooks read the same gold tables again and again, and a downstream mart copies the whole orders table every night, only to find the few rows that changed. One query also takes ten minutes, and nobody knows why. This lesson covers the disk cache, the change data feed, and the query profile.
The disk cache
The disk cache, formerly the Delta cache, keeps local copies of Parquet files, including those of Delta tables, on the SSDs of the workers, the first time they are read. Later reads of the same data come from the local disk, which is much faster than cloud storage. It works automatically on compatible instance types, and when the files change, the cache notices, so results stay correct. The Spark cache, with cache or persist on a DataFrame, keeps data in memory, must be set up by hand, and fits intermediate results, rather than tables that are read again and again. And cache select is ignored on recent runtimes, so there is nothing to warm up by hand.
The change data feed
The change data feed captures the row level changes between versions of a Delta table: inserts, updates, and deletes. Each change row carries _change_type, set to insert, update_preimage, update_postimage, or delete, with _commit_version and _commit_timestamp. In SQL, table_changes, with the table and a starting version, returns the changes, and in Python, the readChangeFeed option does the same, in batch or as a stream. It is turned on per table with delta.enableChangeDataFeed, and recent runtimes can also compute the changes automatically, from row tracking. Downstream tables then process only what changed, instead of comparing full copies.
The query profile
The query profile shows how a query ran, as a tree of operators, with the time, the rows, and the memory of each one. Start with the operators that took the most time, then check the scans: the files and bytes pruned show whether data skipping worked, and a full scan shows that it did not. Exchanges, or shuffles, move data between executors, and large ones point to joins or aggregations that need attention. The join strategy shows a broadcast or a sort merge join, and a join that returns far more rows than it reads, an exploding join, often means a wrong or missing join key. To see a profile, you must own the query, or have the CAN MONITOR permission on the SQL warehouse.
Recap
Let's recap. The disk cache keeps local copies of table files on the SSDs of the workers, automatically, and stays correct when files change. The Spark cache is manual and in memory, for intermediate results. The change data feed returns row level changes, with _change_type, through table_changes or readChangeFeed. For updates, keep the update_postimage rows. And the query profile shows the slowest operators, the files pruned, the shuffles, and the join strategy.
Quick checks for this lesson
The 3 questions of this lesson, as plain text. The button above runs them with shuffled choices and the reason behind every choice.
Several notebooks on a cluster read the same gold tables again and again during the morning. What gives faster repeated reads, with no code change?
- The disk cache, on instances with local SSDs
- cache() on every DataFrame
- CACHE SELECT before each read
- A larger driver node
Show the answer
The disk cache, on instances with local SSDs
The disk cache keeps local copies of the files on the SSDs of the workers, automatically. “cache() on every DataFrame” would need a code change in every notebook, and would hold the data in memory. “CACHE SELECT before each read” is ignored on recent runtimes. And “A larger driver node” would grow the driver, which does not read the table files.
A job reads the change data feed of the orders table, and gets two change rows for every update. It must apply the new values to a downstream table. Which rows should it keep for updates?
- update_preimage rows
- update_postimage rows
- Only insert rows
- Rows with the lowest _commit_version
Show the answer
update_postimage rows
Update_postimage rows hold the values after the update. “update_preimage rows” holds the values before the update. “Only insert rows” would skip every update. And “Rows with the lowest _commit_version” would keep the oldest version, not the newest one.
A query filters the large orders table by city, and its profile shows that no files were pruned in the scan. The table is clustered by restaurant. What should the data engineer do?
- Add a BROADCAST hint to the query
- Raise the number of shuffle partitions
- Read the table through the disk cache
- Cluster the table by city as well
Show the answer
Cluster the table by city as well
Clustering by city lets the scan skip the files that hold other cities. “Add a BROADCAST hint to the query” would only change how a join runs, and the scan would still read every file. “Raise the number of shuffle partitions” would change the shuffle, which is not where the time goes here. And “Read the table through the disk cache” would speed up later reads, but still read every file.