🗄️ Database Design / Normalization
Intermediate
What is query optimization and what is a query execution plan?
Answer
The query optimizer is a component of the RDBMS that analyzes SQL queries and determines the most efficient way to execute them — choosing join algorithms, join order, and whether to use indexes. The query execution plan (or explain plan) is the optimizer's chosen strategy. Use EXPLAIN SELECT ... (MySQL/PostgreSQL) to see the plan. Key operators: Seq Scan (full table scan — potentially slow), Index Scan (uses index — fast), Hash Join, Nested Loop Join, Merge Join. Look for high row estimates, missing indexes, and expensive sorts. The optimizer uses table statistics (row counts, column cardinality) — run ANALYZE (PostgreSQL) to update them.
Previous
What are dirty reads, non-repeatable reads, and phantom reads?
Next
What is a covering index?
More Database Design / Normalization Questions
View all →- Intermediate What are database anomalies and how does normalization prevent them?
- Intermediate What is denormalization and when is it used?
- Intermediate What are isolation levels in database transactions?
- Intermediate What are dirty reads, non-repeatable reads, and phantom reads?
- Intermediate What is a covering index?