Skip to content

Sync Modes

Yoda supports two strategies for applying CDC events from the OLTP log to the OLAP mirror. Choose Destructive when you only need the current state of your data, or Temporal when you need a full history of changes for point-in-time queries and audit trails.

Configure the mode in HtapConfig before starting the engine. It cannot be changed at runtime without dropping and recreating the OLAP tables.

rust
use yoda::{HtapConfig, SyncMode};

let config = HtapConfig {
    sync_mode: SyncMode::Temporal,
    ..HtapConfig::default()
};

SyncMode::Destructive (default)

The OLAP table is a current-state mirror of the OLTP table.

OLTP operationOLAP effect
INSERTRow inserted into OLAP.
UPDATEExisting OLAP row overwritten in place.
DELETERow removed from OLAP.

This is the simplest mode and uses the least storage. It is ideal when you only need up-to-date analytics and have no requirement to query historical states.

SyncMode::Temporal (SCD Type 2)

Every CDC event appends a new row — no row is ever modified or deleted. The OLAP table grows as a time-ordered history, with three metadata columns (_yoda_valid_from, _yoda_valid_to, _yoda_operation) tracking version validity.

A point-in-time query reads the table as it existed at timestamp T:

sql
SELECT *
FROM   users
WHERE  _yoda_valid_from <= T
  AND  (_yoda_valid_to IS NULL OR _yoda_valid_to > T)

For the full mechanics — how UPDATE and DELETE events translate to close-and-append SQL pairs, atomicity guarantees per backend, the worked schema, current-state and history queries, and a complete CLI walkthrough — see Advanced → Temporal Mode (SCD-2).

Choosing a Mode

ConsiderationDestructiveTemporal
Storage growthBounded (current rows only)Unbounded (full history)
Point-in-time queriesNoYes
Audit / complianceNoYes
Query complexitySimpleRequires _yoda_valid_from/to filter
DuckDB atomicityN/AFully atomic close + insert
DataFusion atomicityN/ABest-effort (sequence-number recovery)

Start with Destructive and switch to Temporal only when you have a concrete need for history. Migrating an existing deployment requires recreating the OLAP tables.

Next Steps

Released under the Apache-2.0 License.