Query Optimization and Execution Plans Questions
Making queries fast: reading and interpreting execution/explain plans, identifying full scans, spotting SQL anti-patterns, and rewriting queries for better performance. Covers how the planner chooses join order and access methods, and how statistics drive those choices. A core skill for anyone responsible for query performance in production.
Define selectivity and cardinality in the context of query optimization. How does predicate selectivity influence both index usage and join order selection, and how would you estimate the selectivity of a predicate from existing table statistics?
What is the difference between EXPLAIN and EXPLAIN ANALYZE (or the equivalent in your database of choice)? Explain what information each gives you, when you would rely on EXPLAIN ANALYZE instead of the plan-only form, and any risk of running EXPLAIN ANALYZE against a production system.
Describe a repeatable methodology for benchmarking a proposed query rewrite (or an index, or a join change) against the current query: how you would capture a fair baseline, control for caching and concurrency, choose metrics, and decide whether an observed improvement is real rather than noise.
A query (or a whole class of queries) that used to run fine has regressed significantly, seemingly overnight, with no application change. Walk through your triage process for narrowing down what changed: what evidence you would gather first, the handful of underlying causes that pattern is usually explained by, and how you would confirm which one actually happened rather than guessing.
You need to explain to a non-technical stakeholder why a proposed index (or a materialized/pre-aggregated table) is worth the write-latency or storage cost it introduces. Lay out the talking points you would use: the benefit in terms they care about, the concrete cost, and how you would validate afterward that it actually helped.
Unlock Full Question Bank
Get access to all 39 Query Optimization and Execution Plans interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.