Incremental Loading 101: Timestamp, Watermarking, Hash Comparisons and CDC

·

·

Incremental Loading 101: Timestamp, Watermarking, Hash Comparisons and CDC

Incremental loading is a key method for efficient ETL and data pipelines. Instead of reading full tables each run, it pulls only the rows that are new or have changed. This approach lowers processing time, reduces resource use, and delivers fresh data faster. We cover four common methods:

  1. Timestamp-based filtering
  2. Watermarking (High-Watermark / Max-Value Tracking)
  3. Hash-based comparison
  4. Change Data Capture (CDC)

In practice, the most important step is to understand precisely how your upstream application handles inserts, updates, and deletes. Ask questions like: does it append new rows in batches or streams changes in real time? Are updates in place overwriting existing records or creating new versions? How and when are records physically removed? By mapping these change patterns—whether event-driven inserts, periodic bulk updates, or soft-deleted flags—you can align your incremental-load design (timestamps, CDC, watermarks, or hashes) to mirror the source’s behavior and ensure no changes slip through the cracks.

TypeHandles UpdatesHandles DeletesReal-Time CapableComplexity
Timestamp-based✓X△ (limited)Low
Watermark-based✓ (if using timestamp)X△ (limited)Low
Hash-based comparison✓△ (expensive)XMedium
CDC✓✓✓High

1. Timestamp-Based Incremental Load

In a timestamp-based incremental load, the ETL process relies on a dedicated timestamp column, often named last_updated, to track newly inserted or modified records since the last run.

On each execution, only rows whose timestamp exceeds the previous extraction checkpoint are retrieved, ensuring that recent inserts and updates are processed efficiently.

SELECT *
FROM source_table
WHERE last_updated > '2025-07-27 23:59:59';

This method can capture updates as long as the source system reliably updates the timestamp field on every change.

However, it cannot detect deleted rows, and does not natively support real-time streaming, freshness depends on how frequently the job runs.

By scheduling shorter batch intervals (for example, every minute), you can approximate near-real-time data ingestion, though at the cost of increased query overhead.

Pros

  • Relies only on an existing timestamp column and minimal configuration
  • No external dependencies or additional services required

Cons / Limitations

  • Requires a reliable and precise timestamp column
  • Cannot capture deleted records
  • May miss updates if the timestamp isn’t updated correctly
  • If records arrive with timestamps older than the last extraction checkpoint, those changes won’t be captured.

2. Watermarking (High-Watermark / Max-Value Tracking)

Watermarking refines timestamp-based extraction by storing a persistent high-watermark, a marker of the highest value seen in a chosen column (such as a timestamp or auto-incrementing ID) in an external control table.

On each run, the ETL job queries only records whose key or timestamp exceeds this stored watermark, ensuring that new inserts are captured without reprocessing overlapping time ranges.

By checkpointing the maximum value, watermarking guards against clock skew and overlapping batches, and survives job restarts with precise checkpointing.

Pros

  • Lightweight and easy to implement
  • Avoids full table scans, improving performance
  • Resilient to failures, as the checkpoint only advances after a fully successful load

Cons / Limitations

  • If the watermark rely on auto-incrementing ID, updates to existing rows cannot be detected
  • Late arrival or out-of-order deliveries in the source table may lead to missing records
  • Requires careful management of the persisted watermark to avoid drift (when the checkpoint lags behind new data, missing records) or staleness (when old values cause reprocessing of already loaded data)

3. Hash-Based Comparison

When timestamp fields are unreliable or nonexistent, hash-based comparison offers a robust alternative for detecting row changes. In this approach, a hash value (for example, MD5 or SHA-1) is computed from the concatenation of all columns of each source record, producing a compact fingerprint. These source-side hashes are then compared against corresponding hash values stored in the target system. Any discrepancy in the hash indicates that a row has been inserted, updated, or deleted (if a previously existing key no longer appears in the source). This method ensures that even subtle data modifications are caught, making it ideal for Slowly Changing Dimension (SCD) Type 2 implementations and scenarios where updates arrive irregularly or without reliable time metadata.

Pros

  • Accurately detects altered rows

Cons / Limitations

  • Computationally intensive because requires full or partitioned scans to recompute hashes
  • Storage overhead for retaining hash columns alongside data
  • Minuscule risk of hash collisions, which could mask true changes
  • Computational expensive to handle delete

4. Change Data Capture (CDC)

Change Data Capture (CDC) elevates incremental loading by tapping directly into a database’s change stream, such as transaction logs or built-in CDC features, to capture every insert, update, or delete event as it occurs. Unlike timestamp-based methods, CDC preserves the exact sequence and type of each change, enabling precise replication and historical auditing.

This approach shines in environments with high transaction volumes, where table scans would be prohibitively expensive or slow.

By streaming only the delta of data changes, CDC pipelines can operate with minimal latency, ensuring downstream systems remain closely synchronized with the source.

It also inherently supports delete detection, making it the go-to choice for systems that require full fidelity of data lineage or bi-directional replication.

Pros

  • Complete change set: CDC reads directly from the source’s transaction logs or built-in change stream, capturing INSERT, UPDATE, and DELETE events in the exact order they occur so that every modification is accounted for.
  • Low-latency delivery: By processing only the delta of data changes instead of scanning entire tables, CDC pipelines can stream the delta to downstream systems within seconds, supporting nearly real-time data synchronization.
  • Minimal impact on OLTP: Since CDC avoids full-table scans and bulk queries, it reduces CPU and I/O pressure on the source data files, ensuring transactional workloads remain unaffected.
  • Preserving the exact sequence of inserts, updates, and deletes

Cons / Limitations

  • Required to setup in source database
  • Can add load to transaction in the source system
  • Keeping log records around long enough for your CDC consumers to process them can increase storage use and maintenance work on the source side.

Choosing the Right Pattern

  • Low-volume or simple schemas: go with Timestamp-Based or Watermarking.
  • High-volume, mission-critical replication: CDC offers full fidelity and near-real-time updates.
  • Unreliable metadata in source: fallback on Hash-Based Comparison to guarantee change detection.
  • Need to track deletes: choose CDC or Hash-Based Comparison.

Each approach trades off simplicity, performance, and completeness. Pick the one that best matches your source system’s capabilities, data volume, and SLAs.