InterviewStack.io LogoInterviewStack.io

Analytical Query Performance and Optimization Questions

Diagnosing and tuning analytical queries on distributed and warehouse engines. Covers reading and reasoning about query plans, join strategy and ordering including broadcast versus shuffle, statistics and cardinality estimation, materialized views and result caching, skew and spill diagnosis, workload management and concurrency, and the cost side of query performance on engines billed by bytes scanned or compute time. The altitude is the deep, engine-specific operational layer: what a real plan on a real warehouse engine is telling you and what to change. Generic single-engine query-tuning fundamentals, the physical layout of the data being scanned, and the choice of which managed platform to run on are covered separately.

MediumTechnical
45 practiced

Write an efficient SQL query for a common analytical pattern (a rolling N-day metric, or daily active users) over a table with billions of rows, partitioned by date. The query should accept a target date parameter, avoid scanning partitions outside the range it needs, and be structured so the result can support incremental or materialized computation rather than a full recompute each time.

MediumTechnical
56 practiced

A query filters a partitioned table with what looks like a clean date predicate, for example WHERE date = CAST(ts AS DATE), but it scans every partition instead of pruning. Explain why wrapping the partition column defeats pruning, and rewrite the predicate to restore it. Name at least two other common patterns that silently disable pruning, and explain why each one does.

MediumTechnical
58 practiced

Explain the difference between an extract (imported/materialized dataset) and a live connection in a BI tool such as Tableau, Power BI, or Looker. What are the trade-offs in latency, freshness, concurrency, and network dependency, and for a dataset with roughly 500 million rows feeding 200 daily dashboards, how would you decide which mode to use, possibly as a hybrid?

MediumTechnical
59 practiced

Your analytics warehouse bills by bytes scanned. Analysts run dozens of exploratory ad-hoc queries a day that scan large date ranges and cost real money. Propose a combination of technical and policy-level strategies to meaningfully reduce spend without hurting analyst productivity.

HardSystem Design
58 practiced

Design a query-serving architecture that supports sub-second, interactive dashboard filtering over a fact table with billions of rows. Compare the levers available (materialized views/rollups at multiple granularities, an OLAP-cube pre-aggregation layer, result/dashboard-layer caching, and approximate aggregation for the heaviest metrics) and explain the storage, freshness, and complexity trade-offs of combining them, including how you would prioritize which lever to try first for an existing slow dashboard.

Unlock Full Question Bank

Get access to all 26 Analytical Query Performance and Optimization interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.