Questions: Query Optimization

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

After a bulk load of 50 million new rows into a table, queries that previously ran in 2 seconds now take 8 minutes. No schema or index changes were made. What is the most likely cause and the correct first step to fix it?

AThe indexes have become corrupted and must be dropped and rebuilt from scratch
BThe table statistics are stale — the optimizer is estimating row counts based on old data and choosing a bad plan; run ANALYZE to refresh them
CThe query must be manually rewritten with SQL hints to force the original execution plan
DThe database server ran out of memory and needs to be restarted
Question 2 Multiple Choice

Why is join ordering considered the hardest sub-problem in query optimization for a query joining many tables?

AJoins can only be performed in the order the tables appear in the FROM clause
BThe number of possible join orderings grows factorially — for n tables, there are n!/2 orderings — making exhaustive search impractical for large n
CJoins always produce more output rows than input rows, so order doesn't matter for cost
DThe database must read all tables into memory before it can join any of them
Question 3 True / False

A cost-based query optimizer typically finds the globally optimal execution plan for a given query.

TTrue
FFalse
Question 4 True / False

Predicate pushdown — applying WHERE filters before joins rather than after — is beneficial because it reduces the number of rows flowing into join operations.

TTrue
FFalse
Question 5 Short Answer

Why does the query optimizer need table statistics like row counts, histograms, and distinct value counts, and what happens to query performance when those statistics become stale?

Think about your answer, then reveal below.