You have a table with one billion rows. How would you update the data in this table on a monthly basis?
💡 Model Answer
When dealing with a table that contains one billion rows, a full overwrite each month is impractical. Instead, use incremental loading: 1) Partition the table by a date column (e.g., month or day) so that only the relevant partition needs to be refreshed. 2) Use a staging table to load the new monthly data, then perform a merge (UPSERT) or delete‑insert based on a primary key. 3) If the source supports change data capture (CDC), capture only changed rows and apply them to the target. 4) For very large volumes, consider using a distributed engine like Spark or Hive to process the data in parallel. 5) After the merge, run a vacuum or compaction to reclaim space. 6) Automate the process with a workflow orchestrator (Airflow, Prefect, etc.) and monitor for failures. Complexity: The merge operation is O(n) for the number of changed rows, and partitioning keeps the scan cost low. Using CDC reduces the amount of data moved, making the process efficient.
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