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

Your team is considering federated queries that read external S3 data directly from the warehouse for ad-hoc analysis, instead of first ingesting it. What are the performance, cost, and governance trade-offs, and what criteria would tell you federation is appropriate versus when you should ingest the data first?

MediumTechnical
57 practiced

An analytics events table stores a JSON payload column that many ad-hoc queries need to reach into, and those queries are slow. Discuss the strategies available to speed this up: schema-on-read versus schema-on-write, extracting frequently-used fields into derived columns, and converting to Parquet with explicit typed columns, with the trade-offs of each.

MediumTechnical
53 practiced

Describe a step-by-step approach to profile and diagnose a slow query in a warehouse engine of your choice (Snowflake's Query Profile, BigQuery job statistics, or Redshift's STL/SVL system tables), or contrast it with reading a Spark SQL logical versus physical plan. Which metrics (bytes/slots scanned, shuffle volume, CPU) are most informative in each, and how would you use them to pinpoint the bottleneck?

MediumTechnical
51 practiced

You must decide whether a customer-lifetime-value report should be computed from raw transaction-level data or from pre-aggregated daily summaries. Explain the trade-offs in latency, accuracy, cost, and interactivity, and recommend which you would choose for an interactive BI dashboard versus a monthly finance report.

MediumTechnical
45 practiced

CTEs (WITH clauses) are convenient but can cause real performance regressions when they are re-materialized on every reference. Given a query with multiple CTEs over large tables, show how you would rewrite it for better performance, and note which engines inline CTEs versus materialize them by default.

Unlock Full Question Bank

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

Sign in to Continue

Join thousands of developers preparing for their dream job.