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.

MediumTechnical
125 practiced

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.

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

Write (or describe) how a LATERAL join can replace a correlated subquery when you need, for each row of an outer table, the top result from a related table (for example the most recent event per user, or the top-N per group). Explain why the LATERAL form is usually more optimizer-friendly than the equivalent correlated subquery.

MediumTechnical
78 practiced

Explain what a bitmap index scan is and why a planner might choose it over either a plain index scan or a sequential scan. What predicate shapes make it attractive, and what does 'lossy' bitmap behavior mean for very large row estimates?

MediumTechnical
83 practiced

For a large fact table partitioned by a date or key column, explain how partition pruning lets the planner skip entire partitions for a query, and what predicate shapes silently defeat it (a function wrapped around the partition column, a predicate that never mentions the partition key, or a join that doesn't align with partition boundaries). Walk through how you would confirm pruning is or isn't happening for a specific query.

Unlock Full Question Bank

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

Sign in to Continue

Join thousands of developers preparing for their dream job.