Code RoomIncremental materialized view maintenance
HardPrep Room Coding #3428

Incremental materialized view maintenance

System designDatabases & SQLSenior–Staff~50 min

Design the storage and maintenance of an incrementally-maintained materialized view that powers a real-time merchant dashboard: 'per-merchant, per-day count and sum(amount) of completed orders', over a base orders table taking 100k writes/sec (inserts, plus status updates that flip an order to/from 'completed', plus refunds/deletes). A full recompute is far too expensive and too stale. Design how the view is stored, how each base-table change updates it incrementally and correctly (including updates and deletes, not just inserts), and the consistency/staleness trade-off the merchant sees.

What a strong answer looks like

Clarify scale and constraints first. Propose a clean component breakdown, then go deep on the hard parts (data model, bottlenecks, consistency, failure modes) and name the trade-offs you are making.

Clarify5:30 left
Estimate5:30 planned
Design16:30 planned
Deep dive13:30 planned
Failure9:00 planned
0:00
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.