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
88 practiced

Design a cache-invalidation strategy for precomputed dashboard results that normally refresh hourly but must also support an ad-hoc user-triggered Refresh. How do you balance cache TTL, manual invalidation requests, and background refresh jobs, and how do you avoid a thundering herd of recomputation exactly at the hour boundary?

MediumTechnical
59 practiced

Given events(id, user_id, amount, event_time) and a materialized daily_user_totals(date, user_id, total_amount), write SQL (or precise pseudo-SQL) that incrementally updates daily_user_totals for only the dates present in a staging_events table, correctly handling inserts, updates, and deletes idempotently while minimizing locks on the target table.

HardSystem Design
63 practiced

Design a system to orchestrate a hierarchy of pre-aggregated tables with dependencies (base fact -> hourly -> daily -> monthly), and route each dashboard query to the correct rollup based on the requested date range and granularity. Explain the incremental refresh algorithm, how you minimize recomputation when an upstream change occurs, and how you handle failure recovery so aggregates stay correct.

MediumTechnical
54 practiced

You optimize a query so it now scans 200 GB per run instead of 5 TB. If the warehouse charges $5 per TB scanned and the query runs 100 times a day, estimate the daily and annualized savings. State your assumptions and what could make the real savings differ.

EasyTechnical
51 practiced

Describe the difference between a materialized view, a warehouse or BI-tool result cache, and a report snapshot. For a high-traffic executive dashboard showing hourly aggregates across many filters, which would you recommend, and what are the trade-offs in freshness, cost, and latency?

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.