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.
Compare nested loop, hash, and sort-merge join algorithms: how each works, its memory and I/O profile, and the conditions under which a cost-based optimizer prefers it. What data properties (sorted input, small build side, high join selectivity) make one algorithm clearly better than the others?
A query plan shows a nested loop join whose estimated row count for a filter step is orders of magnitude lower than the actual row count, and the query is timing out. Walk through how you would confirm this is a cardinality-estimation problem rather than something else, and what your remediation path would look like from fastest-to-apply to most invasive.
What is predicate pushdown, and why does it matter for query performance, especially against columnar storage formats (Parquet, ORC) or a foreign data wrapper? Give a concrete example where moving a filter earlier in a query (for example into a subquery or a join) lets the engine reduce how much data it reads, and describe how you would verify from the plan that pushdown is actually happening rather than assumed.
Compare IN, EXISTS, and JOIN as ways to test membership in another table. Cover how NULLs change the semantics of each (particularly for a large IN list or a NOT IN), when the optimizer is free to transform one into another, and when the choice actually changes performance rather than just readability.
Every index you add speeds up some reads and slows down every write to that table. Explain the mechanism (what actually happens on INSERT/UPDATE/DELETE), and describe how you would decide, for a table with a heavy write rate, whether a proposed index is worth that cost.
Unlock Full Question Bank
Get access to all Query Optimization and Execution Plans interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.