HomeInterview QuestionsYou have a source table with 1 billion records. Yo…

You have a source table with 1 billion records. You don't want to reload everything every day. How would you design an incremental load strategy?

🟡 Medium System Design Mid level
1Times asked
Aug 2026Last seen
Aug 2026First seen

💡 Model Answer

A robust incremental load strategy for a 1‑billion‑row source table relies on capturing only the changes that occurred since the last load. First, add a monotonically increasing surrogate key or a timestamp column (e.g., last_modified) to the source. During each run, query the source for rows where the key or timestamp is greater than the maximum value processed in the previous run. If the source does not support such columns, use a change data capture (CDC) mechanism like database triggers, log mining, or a third‑party CDC tool to capture inserts, updates, and deletes.

Once the changed rows are identified, load them into a staging area. For inserts and updates, perform an upsert (merge) into the target dimension or fact table, matching on the surrogate key or natural key. For deletes, either mark the record as inactive or physically delete it, depending on business rules.

To keep the process efficient, partition the source and target tables by a date or key range, and use parallel processing or batch windows (e.g., 1‑hour windows) to avoid long locks. Maintain a metadata table that records the last processed key or timestamp, ensuring idempotency and enabling recovery if a run fails.

Complexity: The query to fetch changes is O(k) where k is the number of changed rows, which is typically far smaller than the total 1B rows. The merge operation is also linear in k. Overall, the incremental load scales with the volume of changes rather than the full table size.

This answer was generated by AI for study purposes. Use it as a starting point — personalize it with your own experience.

🎤 Get questions like this answered in real-time

Assisting AI listens to your interview, captures questions live, and gives you instant AI-powered answers on a discreet on-screen overlay.

Get Assisting AI — Starts at ₹500