Skip to content
tezvyn:

Optimizing a Slow, Expensive Data Warehouse for BI Dashboards

Source: docs.cloud.google.comHardHow cards are made

Tests your grasp of data warehouse architecture beyond basic SQL. A great answer covers partitioning/clustering, materialized views for pre-aggregation, and cost controls. A red flag is suggesting only query rewrites or just 'adding more compute'.

What's really being asked

This question tests your ability to think systemically about data performance and cost at scale. The interviewer is looking for a multi-layered strategy that goes beyond simple query tuning. They want to see if you understand the core architectural features of modern columnar data warehouses (like BigQuery or Snowflake) and can apply them to a real-world business problem involving both latency (slow dashboards) and budget (expensive queries).

The full answer

A great answer proposes solutions in three distinct layers, from the physical storage up to the query execution. First, physical data layout optimization. The most critical step is partitioning the raw event table, almost always by a date or timestamp column. This is the single most effective way to prune data for time-series analysis. Then, add clustering on columns frequently used in WHERE clauses, such as user_id or region, to further reduce the amount of data scanned within each partition. Second, pre-computation. Propose creating materialized views or summary tables that aggregate the raw data to the specific grain needed by the dashboards (e.g., daily active users per country). This shifts the heavy computation from query time to ingestion time, making dashboards fast and cheap to run. Third, cost and query governance. Mention using the query plan analyzer to identify expensive full-table scans. Discuss implementing platform-specific cost controls, like setting a maximum bytes billed per query or per user in BigQuery, and evaluating the pricing model (e.g., moving from on-demand to flat-rate pricing for predictable BI workloads).

The mistakes people make

The most common red flag is a junior-level answer that focuses only on rewriting the SQL queries. While important, it's insufficient for billions of rows. Another weak answer is to simply suggest 'throwing more hardware at it' or 'increasing the warehouse size', which shows a misunderstanding of both cost control and the auto-scaling nature of modern data warehouses. Using incorrect terminology, like 'adding an index' instead of the correct terms 'partitioning' and 'clustering' for columnar stores, is also a negative signal. Finally, an answer that ignores the 'expensive' part of the prompt and only solves for 'slow' is incomplete.

What usually comes next

Expect follow-ups like: 'How would you choose the clustering columns?' (Answer: Analyze dashboard filter usage; pick 1-4 high-cardinality columns that are most frequently used together in WHERE clauses). 'When would you use a materialized view versus a manually managed summary table?' (Answer: MV for simplicity, automatic refresh, and query rewriting support. Manual summary table for complex, multi-stage transformations or when you need fine-grained control over the refresh schedule via an orchestrator like Airflow).

A concrete example

For a table with 2 billion events per month (~2TB of new data), partitioning by day is essential. A query for a single day's activity would then scan only ~67 million rows (~65GB) instead of 2TB, a 97% reduction in data scanned. If dashboards frequently filter by user_id, clustering on that column would then co-locate a specific user's data within that day's partition. This could reduce a query for one user's activity from scanning 65GB to just a few hundred megabytes. An aggregate materialized view of 'daily active users' would be a tiny table, making the dashboard load instantly and cost fractions of a cent per query.

Interview question

A BI dashboard querying a multi-billion row event table is slow and exceeds budget. What is the most effective architectural change to address both issues?

  • a.Refactor all dashboard SQL queries to use common table expressions (CTEs) and reduce complex joins.
  • b.Create B-tree indexes on the most frequently filtered columns, such as user_id and event_timestamp.
  • c.Partition the table by date and create materialized views that pre-aggregate data to the dashboard's required granularity.Correct
  • d.Increase the warehouse's compute resources and cache size to handle the heavy query load more quickly.
Why?

Partitioning by date drastically reduces the data scanned, lowering both cost and latency. Materialized views serve pre-computed results, making dashboards fast and cheap. Creating indexes (Option B) is incorrect terminology for most columnar warehouses, which use clustering instead.

Just read this? Test yourself on what you have been reading.

Read the original → docs.cloud.google.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.

Get it on Google PlayiPhone app coming soon

We are hiring for this. Every open role lists the topics its interview covers, so you can prepare for the real thing rather than guessing.

See open roles