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.

HardTechnical
74 practiced

Explain parameter sniffing: how a cached plan compiled for one parameter value can become a bad plan for a very different parameter value on the same query. Walk through at least three mitigation strategies and the trade-off each one carries (plan quality vs. compilation overhead vs. operational complexity).

MediumTechnical
91 practiced

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?

MediumTechnical
138 practiced

What conditions must be satisfied for an index-only scan to actually happen (rather than an index scan followed by a heap lookup)? Include the role of the visibility map and vacuuming, and describe how you would check, for a specific query and index, whether an index-only scan is actually being used and why not if it isn't.

MediumTechnical
68 practiced

Describe a practical approach for detecting both missing and redundant (or unused) indexes in a production database. Which system views, catalogs, or extensions would you query, and what evidence would make you confident enough to actually drop an index rather than just flag it?

MediumTechnical
92 practiced

Compare the performance implications of Common Table Expressions (CTEs), inline derived tables, and temporary tables for an intermediate result that is reused within a larger query. In what circumstances does a CTE hurt rather than help, and how would you decide between the three approaches for a specific slow reporting query?

Unlock Full Question Bank

Get access to all 39 Query Optimization and Execution Plans interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.