API Design · Senior · Question 43 of 75
What's a good way to expose computed aggregates that are expensive, like monthly revenue per customer?
- ✓Correct answer: Precompute them (materialized views, rollup tables or a reporting store) and expose them as read-only resources with clear freshness
- 2Compute them on every request from raw data
- 3Ask clients to compute them from raw exports
Explanation
Document how fresh the numbers are (e.g. updated hourly) so clients don't treat them as real-time.