Full, Incremental, and Bookmarks

Concepts covered: Full vs Incremental Load

Every ingestion run against a database first decides which rows to read. A full load reads every row and replaces the target copy. An incremental load reads only rows changed since the previous run and merges them into the target by primary key, which depends on a small piece of saved state.

Full load: read everything, replace everything

A full load runs a SELECT over the whole table and overwrites the target. Correctness comes built in. Every change shows up, hard deletes included, because the target becomes an exact copy as of the read, and the next run repairs a bad one. The cost grows with the size of the table, whatever the amount of change. The stores table has 1,800 rows; the orders table has 40 million, and a nightly full load reads all of them even on a day when only 300,000 changed.

Incremental load: read only what changed

An incremental load needs a column that moves forward every time a row changes: usually updated_at, set by the application on each write, or an ever-growing id for tables that only receive inserts. Each run reads rows past the point the previous run reached and upserts them by primary key. The column needs an index on the source, or every small run still scans the whole table to find its rows.

Incremental loads have 2 blind spots. A hard delete removes the row, so its updated_at never moves again and the target keeps the order forever. A write that skips updated_at, such as a bulk fix run by hand, is invisible too. Teams cover both with a periodic full comparison, or by moving to change data capture, the next section's subject.

Full load
  • Reads every row on every run
  • Catches every change, hard deletes included
  • Needs no change-tracking column
  • The next run repairs a bad run
  • Cost grows with table size
Incremental load
  • Reads rows changed since the bookmark
  • Misses hard deletes and untracked writes
  • Needs a reliable updated_at or growing id
  • Needs a bookmark store and a keyed upsert
  • Cost grows with change volume

The bookmark store

The point an incremental load has reached is its bookmark, also called its high-water mark. It is the only state carried between runs, so where it lives and when it is written decide whether rows get lost. A bookmark in a file on the worker vanishes when the worker is replaced. Keep it in a small table in a durable database.

Schema
  • ingest_bookmarks: source_table varchar PK, run_id bigint PK, low_bound timestamp, high_bound timestamp, rows_loaded bigint, committed_at timestamp

Each run inserts a row holding both bounds of its window. The history buys 2 things over a single overwritten value: a backfill of a bad hour replays exactly that run's window, and gaps between consecutive windows show up in a query. The next run starts from the latest row.

SELECT
  high_bound
FROM ingest_bookmarks
WHERE source_table = 'orders'
ORDER BY run_id DESC
LIMIT 1

Write the bookmark last

The run loads and commits its window first, and only after that commit does it insert its bookmark row. If the worker dies between the data commit and the bookmark insert, the next run reads the old bookmark and loads the same window again; the upsert by primary key makes that replay harmless. Reverse the order, and a crash after the bookmark insert skips the window forever, with no error anywhere.

The bounded query

The tempting query filters WHERE updated_at > :bookmark and saves the largest updated_at it saw as the next bookmark. That loses rows. The application stamps updated_at when the statement runs, but other sessions see the row only once its transaction commits. A transaction that stamps 09:59:58 and commits at 10:00:03 is invisible to a query running at 10:00:01. That query saves a bookmark about 10:00:00, and every later run starts after the late row.

The fix is a window whose ends are both fixed before the read starts. The lower bound is the stored bookmark. The upper bound is the run's start time minus a safety lag longer than the source's longest transaction. With a 5-minute lag, the 10:00 run stops at 09:55, and the row stamped 09:59:58 lands in the 11:00 run's window, long after its commit. An id bookmark has the same gap, because id 5001 can commit after id 5002; for insert-only tables, bound a created_at timestamp with the same lag instead.

SELECT
  order_id,
  total,
  updated_at
FROM orders
WHERE updated_at > TIMESTAMP '2026-03-14 08:55:00'
  AND updated_at <= TIMESTAMP '2026-03-14 09:55:00'
Run startsLower bound (excluded)Upper bound (included)Bookmark saved
10:0008:5509:5509:55
11:0009:5510:5510:55
12:0010:5511:5511:55

The strict > on the lower bound and <= on the upper make consecutive windows meet with no gap and no overlap, so a row stamped exactly 09:55:00 belongs to the 10:00 run alone. The lag costs freshness: a row reaches the warehouse 5 to roughly 65 minutes after it is stamped, the lag plus up to one hourly interval.

An hourly job on orders was changed to insert its bookmark row first and load the window second. Tonight the worker is killed right after the bookmark insert. What does the next run do?

About this lesson

This section is part of the Ingestion Patterns: Intermediate lesson on DataDriven, the home of data engineering. Lessons cover SQL, Python, Spark, data modeling and pipeline architecture, and each section pairs its explanation with worked examples and practice you run as you go.