InterviewStack.io LogoInterviewStack.io

Query Optimization and Execution Plans Questions

Focuses on diagnosing slow queries and reducing execution cost through analysis of query execution plans and systematic query rewrites. Candidates should be able to read and interpret explain output and execution plans including identifying expensive operators such as sequential table scans index scans sorts nested loop join hash join and merge join and explaining why those operators appear. Core skills include cost and cardinality estimation understanding join order and predicate placement predicate pushdown and selectivity reasoning comparing exists versus in versus join patterns and identifying common anti patterns such as N plus one queries. The topic covers profiling and benchmarking approaches using explain analyze and runtime statistics comparing estimated and actual row counts proposing and validating query rewrites and configuration or schema changes and reasoning about trade offs when using materialized views caching denormalization or partitioning to improve performance. Candidates should present step by step approaches to diagnose problems measure improvements and assess impact on other workloads.

HardSystem Design
94 practiced
A mission-critical dashboard needs sub-100ms responses for a high-concurrency user base. Propose a layered approach combining pre-aggregation, in-memory cache, and query optimization. For each layer describe how you'd measure latency improvements and mitigate data staleness risks.
HardSystem Design
144 practiced
An operational ETL job updates a reporting table during business hours and causes locking that slows dashboard queries. Propose strategies (copy-then-swap, partition-based swap, online-updates with transactional batches) to minimize locking and quantify their pros and cons for availability and complexity.
MediumTechnical
73 practiced
A BI analyst notices wide variance between cold-cache and warm-cache query times. Explain how caching (OS cache, DB buffer cache, CDN) affects EXPLAIN ANALYZE results and how you would design performance tests that separate cold-cache baseline from steady-state performance for regression analysis.
HardTechnical
72 practiced
You suspect index bloat is causing poor index performance and planner decisions. Explain how you would detect index bloat, what maintenance operations (VACUUM, REINDEX, CLUSTER) can fix it, and the operational considerations (downtime, locks, IO) for each in a production BI database.
HardTechnical
75 practiced
A complex dashboard pulls data from multiple databases via federated queries and is extremely slow. Evaluate pros and cons of three strategies: ETL into a central warehouse, using async replica sync, or pushing computation to the source databases. Recommend which to choose for a BI product that needs freshness within 5 minutes.

Unlock Full Question Bank

Get access to hundreds of Query Optimization and Execution Plans interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.