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

You expected a hash join in a plan and instead see a nested loop over a large input. Give at least three distinct reasons the planner might make that choice, and for each, what you would check or change to encourage a better plan.

MediumBehavioral
75 practiced

Tell me about a time you diagnosed and fixed a real production database performance problem. Using the STAR format, describe how you noticed and measured it, what you changed, and the concrete impact once it shipped.

HardTechnical
131 practiced

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.

HardTechnical
92 practiced

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.

EasyTechnical
94 practiced

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?

Unlock Full Question Bank

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

Sign in to Continue

Join thousands of developers preparing for their dream job.