Syncing the warehouse into your own systems
If you connect via JDBC/ODBC to replicate warehouse data into your own database or lake, you do not need periodic full re-downloads. Every table exposessynced_at — the moment each row was written or last corrected — designed exactly for incremental extraction.
The pattern
Keep one watermark (T_prev) per table in your system, then on every sync cycle:
Why each step matters
- Freeze
Tonce (step 1). Usingnow()inside your queries makes every page of a long extraction see a different instant. Freezing one timestamp makes the whole extraction a consistent snapshot. - UPSERT, never blind INSERT (step 3). When the warehouse corrects a row (a delivery status lands, a late CRM id arrives), it re-emits the same business key with a fresh
synced_at. An upsert replaces your stale version; a blind insert would duplicate it. Every table’s key is its*_idcolumn (session_id,message_id,deployment_id, …). - Replace the hot window (step 4). In rare cases a row can disappear from a table (for example, a duplicate created by an internal correction being cleaned up). A query can return what exists — it cannot tell you what stopped existing. Re-pulling a short recent window by event date (
created_at/scheduled_at) and replacing that slice in your copy guarantees your data matches ours, including removals. Three days is a comfortable window; all corrections happen within 48 hours.
Reference cycle (example: campaign sends)
Initial load
The first sync is the same mechanism withT_prev at zero: pull everything with synced_at <= T, in date-bounded chunks if the table is large, then start cycling. No special case.
What not to do
- Don’t re-download history on a schedule — consolidated data (older than 48 hours) is immutable; re-pulling it is pure cost.
- Don’t build cutoffs from your own clock — always compare against
synced_atvalues read from the warehouse. - Don’t skip the upsert — corrections are a feature, not an anomaly; your copy should absorb them.