The Runtime Theory
mediumSystemInternals#explain-the-model#reason-about-tradeoffs

Explain Reading a Query Plan as an Execution Hypothesis

Explain the model, execution steps, complexity, and limits of reading a query plan as an execution hypothesis.

TRT practice prompt — not a verified question from a named employer.

The Runtime Theory Team6 min read

Interview prompt

Explain reading a query plan as an execution hypothesis to an engineer who understands the surrounding system but has not used this technique. Walk from its contract to a concrete operation, then discuss where it fails or becomes expensive.

A strong answer

A query planner estimates alternative ways to produce a result and chooses one using statistics and cost assumptions. A plan is an executable tree of operators such as scans, joins, sorts, and aggregates. Reading it helps explain where rows are found and how intermediate results are combined.

In a nested-loop join, the inner plan may run once for each outer row; that is attractive when the outer side is small and the inner side has an index. A hash join builds a hash table from one input and probes it with the other, often fitting larger unsorted equijoins.

A complete answer also calls out the assumptions that control correctness. Estimated row counts can diverge from actual counts when statistics are stale or data is correlated. A plan cost is not a direct elapsed-time promise. Compare estimated and actual rows, buffers, and timing, then identify the earliest point where the plan’s assumptions stop matching reality.

Close by describing one representative test or measurement. An index exists but a query still uses a sequential scan. List three plausible reasons and the evidence in an execution plan that would help distinguish them.

Follow-up questions

Answer the follow-ups in the frontmatter. Use the linked article for the concept and the trace to make the explanation concrete.

This answer walks

Practice follow-ups

  1. 01Which assumption is essential for the approach to be correct?
  2. 02What is the worst case, and how does it change the resource cost?
  3. 03How would you adapt the design if the input or workload became much larger?
  4. 04What boundary test would give you the most confidence in the implementation?

One dispatch a week

The trace behind each question, the tradeoff that explains it, and one technical dispatch per week — no noise.

One technical dispatch per week. No noise.

Not started

Sign in to save your learning progress.

Sign in to save