InterviewStack.io LogoInterviewStack.io

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

You run EXPLAIN for a query filtering on a column that has an index, and the planner still shows a sequential scan. Give at least four distinct reasons the planner might legitimately prefer a scan here, and for each, describe how you would check whether that reason applies.

HardTechnical
72 practiced

A user reports that a query runs fast when they test it directly against the database, but slow through the BI tool or application connecting via a read replica, and EXPLAIN ANALYZE shows a different plan shape on the replica. What are the plausible causes, and how would you isolate which one is actually responsible?

MediumTechnical
75 practiced

A query filters on a column that has an index, but wrapping that column in a function or an implicit type conversion is silently preventing the index from being used. Walk through how you would confirm that is what's happening, and the different ways you could restore index usage (query-side and, where appropriate, schema-side).

MediumTechnical
73 practiced

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.

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.