Trade-offs: Pre-aggregation vs. querying raw event data

This tests your grasp of data engineering trade-offs for analytics dashboards. A great answer contrasts pre-aggregation (fast, cheap, stale) with on-the-fly queries (slow, costly, fresh) and mentions hybrid solutions.
What's really being asked
This question assesses your ability to architect data solutions for real-world constraints. Interviewers are looking for a nuanced understanding of the trade-offs between performance, cost, data freshness, and analytical flexibility. They want to see that you can move beyond theoretical ideals and design a practical system that balances competing business and user needs for a high-traffic analytics dashboard.
The full answer
A strong answer methodically evaluates both approaches against the four factors provided. First, define pre-aggregation as creating summary tables (materialized views) to serve common queries, and on-the-fly as querying raw, granular data directly. Second, analyze the trade-offs: pre-aggregation offers low latency (<1s) and low query cost (especially on OLAP systems like BigQuery/Snowflake) at the expense of data freshness (minutes/hours stale) and analytical flexibility (queries must exactly match the pre-aggregated columns). Third, contrast this with on-the-fly queries, which provide perfect freshness and flexibility but suffer from high latency (seconds/minutes) and high cost at scale. Finally, conclude that a hybrid approach is usually best: use pre-aggregations for common dashboard views and allow drill-downs to query raw data for ad-hoc analysis.
The mistakes people make
The most common red flag is absolutism—declaring one approach universally superior without considering context. A junior candidate might say "always pre-aggregate for speed," ignoring use cases that demand real-time data. Another mistake is ignoring the scale implied by "high-traffic." A solution that works for 10 users will fail for 10,000. Finally, a subtle error is failing to mention the challenges of pre-aggregating non-additive measures (like distinct counts), which can lead to cache misses and negate the performance benefits.
What usually comes next
Expect questions like: "How would you decide which queries to pre-aggregate?" (By analyzing query logs for common patterns). "How do you handle requests for data not in the summary table?" (The system should gracefully fall back to querying the raw data). "Your P95 latency target is 200ms. How does that change your design?" (It forces aggressive pre-aggregation for almost all initial views).
A concrete example
For a popular e-commerce dashboard, the main view shows sales by day. Pre-aggregating this into a summary table of (date, total_sales) makes the main chart load in <200ms, even with billions of raw order events. A query to the raw table might take 15 seconds and cost $0.50 per user refresh on BigQuery. The summary table is refreshed every 5 minutes, which is an acceptable freshness trade-off for this view. If a user wants to see individual orders for a specific hour, they can drill down, triggering a slower, more expensive query against the raw data, which is an acceptable user experience for a less common action.
Interview question
When designing a high-traffic analytics dashboard that needs both rapid display of common metrics and the ability for users to perform detailed, ad-hoc analysis, what is the most effective data strategy?
- a.Implement a hybrid model, serving common dashboard views from pre-aggregated data and allowing drill-downs to query raw data.Correct
- b.Query raw event data directly for all dashboard components to guarantee perfect data freshness and support any user-defined query.
- c.Rely exclusively on pre-aggregated summary tables to ensure consistent sub-second query performance for all user interactions.
- d.Use a real-time streaming database for all data, ensuring both freshness and low latency for every query.
Why? this is the answer
The card emphasizes that a hybrid approach is usually best, balancing the low latency and cost efficiency of pre-aggregations for common views with the flexibility and freshness of raw data for ad-hoc analysis. Option B, while offering perfect freshness and flexibility, would lead to high latency and cost at scale for a high-traffic dashboard.
Just read this? Test yourself on what you have been reading.
Read the original → docs.embeddable.com
You just looked this up. Could you explain it out loud?
That is the part interviews actually test. Tezvyn takes questions like this one and gives you what the interviewer is really checking, the answer that lands, and the mistake that ends the conversation, in the four minutes before your next meeting.
The iPhone app is on the way
We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.
Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.
We are hiring for this. Open roles that interview on data engineering — each one lists the topics its interview covers.
See open roles