Skip to content

A scenario for a data engineer · Senior and up

Reading a billion rows to find a thousand

Chief · Your manager
Tuesday, 07:30

A nightly job on Databricks copies changes from a Delta customers table of a billion rows to a search system. It finds them by comparing the whole table with yesterday's copy. About a thousand rows change in a day.

What do you do?

Tap the one you would do. The answer opens below.

Show the best call

Turn on row tracking for the table, then read its change data feed from the last version processed and send only those rows.

The job reads only the day's changes, with inserts, updates and deletes marked. It finishes in minutes.

Why

Change data feed tracks changes to the rows of a Delta table between versions. Each change record holds the row and whether it was inserted, updated or deleted. A job reads it with table_changes or the readChangeFeed option from the version it last handled, and that is what an incremental load or a sync to another system needs. The table needs row tracking on, or the older change data feed setting turned on.

Read it in the Databricks docs (opens in a new tab)

The other two

Works, at a price. Add an updated_at column and filter on it each night.
Updates and inserts are found quickly. A deleted row has no updated_at, so deletes never reach the search system.
A poor call. Give the comparison a bigger cluster.
The same billion rows are read twice a night, faster, for more money.

Go deeper on brickster.ai

More scenarios

Had one like this at work? Send it to us: the best tickets come from real incidents.

Added on . Checked against the Databricks documentation on . brickster.ai is independent and is not affiliated with Databricks.