Interview replay
Full round replay — composite indexes
Timed verbal replay with pass/fail criteria per follow-up.
How to run this
The opener
“Does an index on (a, b) help a query filtering only on b?”
Budget: 45 seconds. Going long here is itself a fail signal.
Follow-ups
1. “Why not? Explain it physically.”
Testing: Reasoning from the sort order, not from a memorised rule.
Scoring
Pass: The index is sorted by a first and only by b within each a, so rows with a given b are scattered across every a block. There is no contiguous range to descend to.
Fail: Repeats the rule with no mechanism behind it.
2. “Are (a, b) and (b, a) interchangeable?”
Testing: Do they treat order as a real decision?
Scoring
Pass: No — different indexes with different capabilities. One serves WHERE a = ? and an ordered read of b within an a; the other serves neither.
Fail: Treats them as the same index written two ways.
3. “How do you choose the column order?”
Testing: The rule, in the right order.
Scoring
Pass: Equality columns first, then the range or ORDER BY column. Seeking stops at the first range column, so anything after it filters row by row rather than narrowing.
Fail: Says most selective first, with nothing else.
4. “Isn't the most selective column supposed to go first?”
Testing: Whether they can rank the two rules.
Scoring
Pass: Usability first. A highly selective column that no query filters on is worthless in the leading position. Selectivity breaks ties between orderings that are all usable.
Fail: Insists selectivity decides.
5. “Index on (a, b, c), query is WHERE a = ? AND b > ? AND c = ?. Is c used?”
Testing: The range-stops-seeking rule.
Scoring
Pass: Not for seeking. Once b is a range, entries in that range are ordered by b and no longer grouped by c, so c is checked row by row. Reorder to (a, c, b) and all three narrow the scan.
Fail: Says all three are used because all three are in the index.
6. “The plan shows my index. Does that mean it is working?”
Testing: Seek versus scan.
Scoring
Pass: No. A full index scan also names the index. Compare rows read with rows returned — a large gap means the index was scanned rather than seeked.
Fail: Takes the plan naming the index as confirmation.
7. “You have (customer_id) and (customer_id, status). Keep both?”
Testing: The redundancy rule and its boundary.
Scoring
Pass: No — the narrow one is a leading prefix of the wider one, so it is redundant. Drop it and save a write per insert. An index on (status) alone would not be redundant.
Fail: Keeps both as insurance.
8. “A query is indexed and still slow. What would you try before adding an index?”
Testing: Widen versus add.
Scoring
Pass: Reorder, or widen an existing index to cover the selected columns. Both cost nothing extra per insert, because write cost is per index rather than per column.
Fail: Adds another index first.
9. “What does a covering index cost?”
Testing: Can they name the downside?
Scoring
Pass: Bigger entries, so fewer per page, a taller index and more cache used. Good for a hot query with a short select list; wrong for SELECT *.
Fail: Says it is free because it removes reads.
Score yourself
← Back to Does an index on (a, b) help a query filtering only on b?