Skip to main content

Change detection logic

How Prequel finds new and changed rows.

High watermark

Where each transfer starts and how that point moves.

Lookback window

How Prequel handles eventually consistent sources.

Duplication behavior

When and why duplicates can occur.

Rows transferred and delta rows

How row counts are calculated.

FAQ

Answers to common questions about change detection.

Change detection logic

Prequel relies on a last_modified_at type column to detect changes between transfers. On a model’s first transfer to a destination (or on a full refresh), the model’s history is transferred, and the greatest last_modified_at value is recorded as the high watermark. Each later transfer reads only rows at or after the high watermark, minus the lookback window. This allows Prequel to predictably transfer batches of updated data.
Incremental transfer query
Use arrival time, not event time, when possible as your last_modified_at columnPrequel’s high watermark is the greatest last_modified_at value seen in the last transfer. Rows with a last_modified_at earlier than the watermark minus the lookback window are not re-queried on the next incremental transfer.Arrival time (when the row was written to your source database, e.g., updated_at set to NOW() by your application on every insert or update) is generally preferred as the last_modified_at column choice.Regardless of when the underlying event occurred, the row’s last_modified_at reflects when it landed in your source, so it will always be above the current watermark and included in the next transfer. This prevents possible out of order data arrival issues.

Timestamp precision

When the greatest last_modified_at value is recorded, it is stored as an epoch, or “unix timestamp”. This value has second precision. For example, if a batch of data is transferred where the greatest last_modified_at timestamp value was 2025-01-01 1:15:30 AM, the equivalent epoch integer will be stored: 1735694130.

High watermark

Prequel stores one high watermark per model per destination: the greatest last_modified_at value transferred for that model. Each incremental transfer reads from the high watermark minus the lookback window, so every model resumes where it left off, independently of the other models on the destination. Prequel moves the high watermark conservatively, so that a failure or an empty result never causes data to be skipped:
  • It advances only when the model transfers successfully. A model that fails during an incremental transfer resumes from its previous high watermark on the next transfer, so the failure does not leave a gap. In a transfer with a PARTIAL_FAILURE status, the models that succeeded still advance.
  • Windowed transfers advance it after each window that transfers rows. If a windowed transfer fails partway, the progress from completed windows is kept, and the next transfer picks up from there.
  • An incremental transfer that finds no new rows leaves it unchanged.
  • A full refresh that finds no rows does not set it. Finding no data in the source is not proof that no data exists up to the present, so Prequel does not record a high watermark from an empty result. The model’s next transfer runs as a full refresh again, so a source that is still being populated is never mistaken for an empty one.
  • An incremental transfer never moves it backward. A transfer whose end_transfer_window_at is earlier than the high watermark leaves it unchanged, and one that ends later advances it to the greatest value transferred.
  • A full refresh resets it to the greatest value transferred by the full refresh.

Full refresh lower bound

Every full refresh, including a model’s first transfer to a destination, picks its lower bound by checking these settings in order and using the first match:
  1. If the transfer request sets start_transfer_window_at on Create transfer, the full refresh reads from that time.
  2. Otherwise, if the recipient sets default_full_refresh_min_start_time_epoch with Update recipient, the full refresh reads from that time.
  3. Otherwise, if the model uses windowed transfers, the full refresh reads from the model’s min_start_time_epoch.
  4. Otherwise, there is no lower bound. The full refresh reads from the Unix epoch (0), which includes all history in the source.

Lookback window

Some sources are eventually consistent, so a row can become visible after rows with a later last_modified_at have already been transferred. This is most common when last_modified_at is set by an external system and does not increase monotonically. To catch these rows, Prequel starts each incremental transfer one lookback window before the high watermark. The lookback window depends on the source vendor:
Lookback window query
The lookback window applies to every incremental transfer:
  • Transfers with an explicit start. When a transfer request sets start_transfer_window_at, Prequel reads from one lookback window before that start. The upper bound is not extended.
  • Windowed transfers. Each window of a windowed transfer applies its own lookback, so a 1-minute window on a source with a 5-minute lookback reads about 6 minutes of data.
The lookback window cannot be configured per source or model. To skip it, filter on {{.LastModifiedAtEpoch}} in a source query. See Skipping the lookback window.

Late-arriving rows

Each incremental transfer only reads rows whose last_modified_at falls within the lookback window or later. A row that is written to your source with an older last_modified_at is skipped and never reaches the destination. For example, on a source with a 5-minute lookback window:
  • Transfer A ends with a high watermark of 12:00:00.
  • A row is then written to the source with a last_modified_at of 11:50:00.
  • Transfer B reads rows with a last_modified_at of 11:55:00 or later, so it skips the row.
  • No later incremental transfer reads it either, so the row never reaches the destination.
This usually happens when last_modified_at records when an event occurred rather than when the row was written. Use arrival time as the last_modified_at column to avoid it. See the tip in Change detection logic. To recover rows that were skipped, run a transfer with start_transfer_window_at set before their last_modified_at, or run a full refresh.

Duplication behavior in Prequel

How Prequel handles duplicate data depends on your destination type:

Database and data warehouse destinations

No duplicates in your tables. Prequel uses upsert operations to ensure that lookback windows do not create duplicate rows in database destinations like Snowflake, BigQuery, PostgreSQL, etc.

Object storage destinations

Duplicates may occur. Object storage destinations (S3, GCS, Azure Blob Storage) are append-only by design, unless using Delta Lake. Lookback windows may cause the same data to be written multiple times and it is the expectation that these are deduplicated by the downstream data pipeline after data is written to the destination.

Primary key requirements

For all destinations, your source data must have unique primary key values within each transfer batch. Duplicate primary keys in your source data will cause transfer errors.

Interaction with a custom source_query

If you choose to use a source_query instead of the default table query, you may wonder how your source query interacts with the change detection queries. In cases where a source_query is used, Prequel applies the same predicate filtering outside of the custom source_query.
Filtering over a source query
Change detection over a source_queryIf your source_query preemptively filters data using a last_modified_at column, you may avoid the safety of the lookback window. In some cases, this may be intentional, but this tradeoff should be considered as you think about your upstream data pipeline.
Timestamp precision in a source_query resulting in missing rowsBecause Prequel only stores the LastModifiedAtEpoch with second precision, comparing that value with a timestamp of higher precision could result in skipped rows.For example, imagine a scenario where:
  • Prequel observes a last_modified_at time of 2025-01-01 00:00:01.600.
  • Prequel records this as an Epoch 1735689601 (corresponding to 2025-01-01 00:00:02).
  • A custom source_query is used, which does not account for rounding/second precision:
    • SELECT * FROM some_source_query WHERE some_last_modified_at_column >= to_timestamp({{.LastModifiedAtEpoch}})
Since the custom source_query does not also round the some_last_modified_at_column to second-level precision, any rows with timestamps between 00:00:01.600 and 00:00:02.00 may be skipped.This can easily be solved by either rounding the some_last_modified_at_column, or implementing your own lookback window.

Rows transferred and delta rows

In the Prequel UI (Transfer details) and API responses, you’ll often see two row counts:
  • Rows (rows_transferred): How many rows were selected from the source for this model in that transfer.
  • Delta rows (delta_rows_transferred): An estimate of how many rows in that transfer have a last_modified_at value newer than the most recent previously completed transfer for that model (the current high watermark).

rows_transferred: how it’s calculated

rows_transferred is an extraction metric: it counts the rows returned by Prequel’s source query.
  • The lower bound is inclusive.
  • The upper bound is exclusive when an end window is specified.
  • A lookback window is applied by querying slightly earlier than the lower bound; rows from this overlap are included in rows_transferred.
Rows transferred count

delta_rows_transferred: how it’s calculated

delta_rows_transferred is a calculated estimate derived from the extracted rows. It counts rows whose last_modified_at is strictly newer than the current high watermark.
  • Included: rows where last_modified_at > high watermark (and within the transfer’s upper bound, if one is specified).
  • Excluded: the lookback overlap (to avoid counting that overlap in delta rows).
Delta rows count
  • Why it can be 0 for historical transfers: If you run a transfer over an older time range, delta_rows_transferred can be 0 even when rows_transferred is large if none of the rows in that window have a last_modified_at value newer than the most recent completed transfer’s high watermark.

FAQ

Yes. Prequel stores a separate high watermark for each model on each destination, so models advance independently. A new model added to a destination runs a full refresh while the other models continue from their own high watermarks.
A model that fails during an incremental transfer keeps its previous high watermark, and the next transfer reads from that point again, so Prequel recovers from failed incremental transfers without leaving gaps or needing a full refresh. In a windowed transfer, windows that completed before the failure are kept.
The rows most likely have a last_modified_at earlier than the high watermark minus the lookback window, which happens when rows are written to the source after newer rows have already been transferred. See Late-arriving rows to prevent this and to recover the rows.
Run a transfer with start_transfer_window_at and end_transfer_window_at set to a range that ends before the high watermark. The transfer reads that range, and the high watermark stays where it is.
delta_rows_transferred counts only rows newer than the high watermark. A transfer over an older time range can read many rows without any of them being newer than the high watermark. See Rows transferred and delta rows.
Each incremental transfer re-reads rows within the lookback window before the high watermark. Warehouse and database destinations upsert these rows by primary key, but object storage destinations write them as new files. Deduplicate them downstream by primary key, keeping the row with the latest last_modified_at.
No. The lookback window is fixed per source vendor and cannot be configured per source or model. To skip it, filter on {{.LastModifiedAtEpoch}} in a source query. See Skipping the lookback window.
No. A model’s last_modified_at column cannot be changed after the model is created. To track changes with a different column, create a new model that uses it.